|
1 | | -name: Discord Notify |
| 1 | +name: Discord PR Review |
2 | 2 |
|
3 | 3 | on: |
4 | | - issue_comment: |
5 | | - types: [created] |
6 | 4 | pull_request_review_comment: |
7 | 5 | types: [created] |
8 | 6 | pull_request_review: |
9 | 7 | types: [submitted] |
10 | 8 |
|
11 | 9 | jobs: |
12 | | - notify: |
| 10 | + notify_review: |
| 11 | + if: ${{ github.actor != 'coderabbitai[bot]' && github.actor != 'coderabbitai' }} |
13 | 12 | runs-on: ubuntu-latest |
14 | | - # ✅ 특정 사람 제외 |
15 | | - if: github.actor != 'coderabbitai' && github.actor != 'coderabbitai[bot]' |
| 13 | + |
16 | 14 | steps: |
17 | | - - name: Send to Discord |
| 15 | + - name: Send PR review comment/review to Discord |
18 | 16 | 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 }} |
20 | 30 | 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