Skip to content

Commit 8dda0bd

Browse files
authored
Update discord_notify.yml
1 parent 586a5c1 commit 8dda0bd

1 file changed

Lines changed: 47 additions & 11 deletions

File tree

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,59 @@
1-
name: Discord Notify
1+
name: Discord PR Review
22

33
on:
4-
issue_comment:
5-
types: [created]
64
pull_request_review_comment:
75
types: [created]
86
pull_request_review:
97
types: [submitted]
108

119
jobs:
12-
notify:
10+
notify_review:
11+
if: ${{ github.actor != 'coderabbitai[bot]' && github.actor != 'coderabbitai' }}
1312
runs-on: ubuntu-latest
14-
# ✅ 특정 사람 제외
15-
if: github.actor != 'coderabbitai' && github.actor != 'coderabbitai[bot]'
13+
1614
steps:
17-
- name: Send to Discord
15+
- name: Send PR review comment/review to Discord
1816
env:
19-
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
17+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
18+
19+
EVENT_NAME: ${{ github.event_name }}
20+
PR_TITLE: ${{ github.event.pull_request.title }}
21+
PR_URL: ${{ github.event.pull_request.html_url }}
22+
23+
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
24+
COMMENT_BODY: ${{ github.event.comment.body }}
25+
COMMENT_URL: ${{ github.event.comment.html_url }}
26+
27+
REVIEW_AUTHOR: ${{ github.event.review.user.login }}
28+
REVIEW_BODY: ${{ github.event.review.body }}
29+
REVIEW_URL: ${{ github.event.review.html_url }}
2030
run: |
21-
curl -H "Content-Type: application/json" \
22-
-d "{\"content\":\"${{ github.repository }}: ${{ github.event_name }} by ${{ github.actor }}\"}" \
23-
"$DISCORD_WEBHOOK"
31+
set -e
32+
33+
if [ "$EVENT_NAME" = "pull_request_review_comment" ]; then
34+
AUTHOR="$COMMENT_AUTHOR"
35+
BODY="$COMMENT_BODY"
36+
LINK="$COMMENT_URL"
37+
else
38+
AUTHOR="$REVIEW_AUTHOR"
39+
BODY="$REVIEW_BODY"
40+
LINK="$REVIEW_URL"
41+
fi
42+
43+
# 링크가 비면 PR 링크로 fallback
44+
if [ -z "$LINK" ]; then
45+
LINK="$PR_URL"
46+
fi
47+
48+
# ✅ 멀티라인 문자열(문제 원인) 제거: printf로 안전하게 조립
49+
msg=$(printf "%s\n%s\n%s\n%s\n%s\n\n%s\n" \
50+
"📝 PR 리뷰" \
51+
"- PR: ${PR_TITLE}" \
52+
"- 작성자: ${AUTHOR}" \
53+
"- 본문:" \
54+
"${BODY}" \
55+
"🔗 ${LINK}"
56+
)
57+
58+
payload=$(jq -n --arg content "$msg" '{content: $content}')
59+
curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" > /dev/null

0 commit comments

Comments
 (0)