Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 디스코드 알림 기능 수정 #37

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions .github/workflows/PR_Comment_Notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
steps:
- name: Set Environment Variables
run: |
echo "AVATAR_URL=${{ secrets.DISCORD_AVATAR_URL }}" >> $GITHUB_ENV
echo "USERNAME=디코봇" >> $GITHUB_ENV
echo "WEB_HOOK=${{ secrets.DISCORD_WEB_HOOK }}" >> $GITHUB_ENV

- name: Set Environment Variables for PR Comments
Expand All @@ -24,8 +22,8 @@ jobs:
echo "PR_URL=${{ github.event.issue.pull_request.html_url }}" >> $GITHUB_ENV
echo "AUTHOR_URL=${{ github.event.comment.user.avatar_url }}" >> $GITHUB_ENV
echo "CONTENT=$(echo '${{ github.event.comment.body }}' | base64 -w 0)" >> $GITHUB_ENV
echo "COMMENT_BODY=${{ github.event.issue.title }}" >> $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

echo "TITLE=Pull Request" >> $GITHUB_ENV
echo "TITLE=${{ github.event.issue.title }}" >> $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 이슈 & PR 제목을 title로 하고 comment_body로 구분해주는 거군요!

echo "COMMENT_BODY=Pull Request" >> $GITHUB_ENV

- name: Set Environment Variables for PR Review Comment
if: ${{ contains(github.event.review.body, '/noti') }}
Expand All @@ -34,8 +32,8 @@ jobs:
echo "PR_URL=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV
echo "AUTHOR_URL=${{ github.event.review.user.avatar_url }}" >> $GITHUB_ENV
echo "CONTENT=$(echo '${{ github.event.review.body }}' | base64 -w 0)" >> $GITHUB_ENV
echo "COMMENT_BODY=${{ github.event.pull_request.title }}" >> $GITHUB_ENV
echo "TITLE=Pull Request" >> $GITHUB_ENV
echo "TITLE=${{ github.event.pull_request.title }}" >> $GITHUB_ENV
echo "COMMENT_BODY=Pull Request" >> $GITHUB_ENV

- name: Set Environment Variables for Issue
if: ${{ !github.event.issue.pull_request && contains(github.event.comment.body, '/noti') }}
Expand All @@ -44,8 +42,8 @@ jobs:
echo "PR_URL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV
echo "AUTHOR_URL=${{ github.event.comment.user.avatar_url }}" >> $GITHUB_ENV
echo "CONTENT=$(echo '${{ github.event.comment.body }}' | base64 -w 0)" >> $GITHUB_ENV
echo "COMMENT_BODY=${{ github.event.issue.title }}" >> $GITHUB_ENV
echo "TITLE=Issue" >> $GITHUB_ENV
echo "TITLE=${{ github.event.issue.title }}" >> $GITHUB_ENV
echo "COMMENT_BODY=Issue" >> $GITHUB_ENV

- name : Set Discord Content
if: ${{ env.CONTENT }}
Expand All @@ -71,9 +69,7 @@ jobs:
- name: Notify Discord
if: ${{ env.COMMENT_AUTHOR && env.PR_URL && env.AUTHOR_URL && env.DISCORD_CONTENT && env.COMMENT_BODY }}
env:
AVATAR_URL: ${{ env.AVATAR_URL }}
COMMENT_BODY: ${{ env.COMMENT_BODY }}
USERNAME: ${{ env.USERNAME }}
WEB_HOOK: ${{ env.WEB_HOOK }}
COMMENT_AUTHOR: ${{ env.COMMENT_AUTHOR }}
PR_URL: ${{ env.PR_URL }}
Expand All @@ -86,8 +82,6 @@ jobs:
JSON_PAYLOAD=$(jq -n \
--arg content "$CONTENT_DECODED" \
--arg description "$COMMENT_BODY" \
--arg username "$USERNAME" \
--arg avatar_url "$AVATAR_URL" \
--arg title "$TITLE" \
--arg url "$PR_URL" \
--arg author_url "$AUTHOR_URL" \
Expand All @@ -96,8 +90,8 @@ jobs:
--arg timestamp "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
'{
content: $content,
username: $username,
avatar_url: $avatar_url,
username: $author_name,
avatar_url: $author_url,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ $author_url은 작성자 프로필 이미지를 가져오는 변수명으로 생각되네요! 좋아요.

allowed_mentions: {
parse: ["users", "roles"]
},
Expand Down
Loading