Skip to content

Commit bbe81fc

Browse files
committed
refactor: 깃헙에 댓글 남기는 방식으로 중복 메시지 없도록 수정
1 parent d549969 commit bbe81fc

1 file changed

Lines changed: 30 additions & 19 deletions

File tree

.github/workflows/pr_revier_request.yml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,58 +10,69 @@ jobs:
1010
- name: Wait for reviewers to settle
1111
run: sleep 10
1212

13+
- name: Check if notification already sent
14+
id: check
15+
env:
16+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
run: |
18+
echo "🔍 Checking for existing notification comment..."
19+
pr_number="${{ github.event.pull_request.number }}"
20+
comment_count=$(gh pr view "$pr_number" --json comments \
21+
| jq '[.comments[].body | select(. | contains("[discord-review-notified]"))] | length')
22+
23+
if [ "$comment_count" -gt 0 ]; then
24+
echo "skip=true" >> "$GITHUB_OUTPUT"
25+
echo "✅ Notification already sent for PR #$pr_number"
26+
else
27+
echo "skip=false" >> "$GITHUB_OUTPUT"
28+
echo "✅ No notification sent yet for PR #$pr_number"
29+
fi
30+
1331
- name: Get unique reviewers
1432
id: reviewers
33+
if: steps.check.outputs.skip == 'false'
1534
env:
1635
REVIEWERS_JSON: ${{ toJson(github.event.pull_request.requested_reviewers) }}
1736
run: |
18-
echo "🔍 Extracting unique reviewers..."
1937
reviewers=$(echo "$REVIEWERS_JSON" | jq -r '.[].login' | sort | uniq | paste -sd "," -)
20-
echo "✅ reviewers: $reviewers"
2138
echo "reviewers=$reviewers" >> "$GITHUB_OUTPUT"
2239
2340
- name: Map to Discord IDs
2441
id: map
42+
if: steps.check.outputs.skip == 'false'
2543
run: |
26-
echo "🔗 Mapping GitHub usernames to Discord IDs..."
2744
declare -A USER_MAP=(
2845
["laggu"]="1269619098405441537"
29-
["sezeme"]="534088965050073089"
3046
["rlooo"]="1060181420389187715"
3147
["yuchem2"]="307875691074945024"
32-
["chsjen492"]="1021785294078480394"
33-
["HeesooJun"]="347294009548341249"
3448
)
3549
3650
mentions=""
3751
38-
# reviewers를 쉼표 기준으로 배열로 다시 split
3952
IFS="," read -ra reviewers <<< "${{ steps.reviewers.outputs.reviewers }}"
40-
4153
for login in "${reviewers[@]}"; do
4254
id=${USER_MAP[$login]}
43-
if [ -n "$id" ]; then
44-
mentions+="<@$id> "
45-
else
46-
echo "⚠️ No Discord ID mapped for $login"
47-
fi
55+
[ -n "$id" ] && mentions+="<@$id> "
4856
done
4957
50-
echo "✅ mentions: $mentions"
5158
echo "mentions=$mentions" >> "$GITHUB_OUTPUT"
5259
5360
- name: Send Discord Notification
61+
if: steps.check.outputs.skip == 'false'
5462
env:
5563
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
5664
MENTIONS: ${{ steps.map.outputs.mentions }}
5765
PR_URL: ${{ github.event.pull_request.html_url }}
5866
run: |
59-
echo "🚀 Sending Discord notification..."
6067
curl -X POST -H "Content-Type: application/json" \
6168
-d "{
62-
\"content\": \"📣 $MENTIONS님! Pull Request 리뷰어로 지정됐습니다.\\n🔗 PR: $PR_URL\",
63-
\"allowed_mentions\": {
64-
\"parse\": [\"users\"]
65-
}
69+
\"content\": \"📣 $MENTIONS님! Pull Request 리뷰어로 지정됐습니다.\\n🔗 PR: $PR_URL\"
6670
}" \
6771
"$DISCORD_WEBHOOK_URL"
72+
73+
- name: Mark notification sent
74+
if: steps.check.outputs.skip == 'false'
75+
env:
76+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
run: |
78+
gh pr comment ${{ github.event.pull_request.number }} --body "[discord-review-notified] 리뷰 알림 전송됨 ✅"

0 commit comments

Comments
 (0)