[FEAT] 종소리 크기 조절 기능 #693
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Discord Notification on PR Comment | |
| on: | |
| issue_comment: | |
| types: [created, edited] | |
| workflow_dispatch: | |
| jobs: | |
| notify-discord-comment: | |
| if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/noti') }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Debug All Event Data | |
| run: echo '${{ toJson(github.event) }}' | |
| - name: Set Environment Variables | |
| run: | | |
| echo "AVATAR_URL=${{ secrets.DISCORD_AVATAR_URL }}" >> $GITHUB_ENV | |
| echo "USERNAME=망곰" >> $GITHUB_ENV | |
| echo "CONTENT=새로운 PR 댓글이 달렸어요!" >> $GITHUB_ENV | |
| echo "WEB_HOOK=${{ secrets.DISCORD_WEB_HOOK }}" >> $GITHUB_ENV | |
| - name: Notify Discord | |
| env: | |
| AUTHOR_NAME: ${{ github.event.comment.user.login }} | |
| PR_URL: ${{ github.event.issue.pull_request.html_url }} | |
| PR_TITLE: ${{ github.event.issue.title }} | |
| COMMENT_BODY: ${{ github.event.comment.body }} | |
| AUTHOR_URL: ${{ github.event.comment.user.avatar_url }} | |
| AVATAR_URL: ${{ env.AVATAR_URL }} | |
| USERNAME: ${{ env.USERNAME }} | |
| WEB_HOOK: ${{ env.WEB_HOOK }} | |
| CONTENT: ${{ env.CONTENT }} | |
| run: | | |
| if [ -n "$WEB_HOOK" ]; then | |
| JSON_PAYLOAD=$(jq -n \ | |
| --arg content "$CONTENT" \ | |
| --arg comment_body "$COMMENT_BODY" \ | |
| --arg username "$USERNAME" \ | |
| --arg avatar_url "$AVATAR_URL" \ | |
| --arg pr_title "$PR_TITLE" \ | |
| --arg pr_url "$PR_URL" \ | |
| --arg author_url "$AUTHOR_URL" \ | |
| --arg author_name "$AUTHOR_NAME" \ | |
| --arg color "5814783" \ | |
| --arg timestamp "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ | |
| '{ | |
| username: $username, | |
| avatar_url: $avatar_url, | |
| content: $content, | |
| embeds: [{ | |
| title: $pr_title, | |
| url: $pr_url, | |
| author: { | |
| name: $author_name, | |
| icon_url: $author_url | |
| }, | |
| description: $comment_body, | |
| color: ($color | tonumber), | |
| timestamp: $timestamp | |
| }] | |
| }') | |
| curl -X POST -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$WEB_HOOK" | |
| else | |
| echo "No matching title found. Skipping notification." | |
| fi |