|
| 1 | +name: Discord PR Notifications |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [review_requested, closed] |
| 6 | + pull_request_review: |
| 7 | + types: [submitted] |
| 8 | + |
| 9 | +jobs: |
| 10 | + review-request-notify: |
| 11 | + if: github.event.action == 'review_requested' |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Send Review Request Notification |
| 15 | + env: |
| 16 | + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 17 | + REQUESTED_REVIEWER: ${{ github.event.requested_reviewer.login }} |
| 18 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 19 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 20 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 21 | + run: | |
| 22 | + case "$REQUESTED_REVIEWER" in |
| 23 | + "chanho0908"|"JoungPeto0908") |
| 24 | + DISCORD_MENTION="<@379613882001391626>" |
| 25 | + ;; |
| 26 | + "dogmania") |
| 27 | + DISCORD_MENTION="<@951268632770531399>" |
| 28 | + ;; |
| 29 | + *) |
| 30 | + DISCORD_MENTION="@$REQUESTED_REVIEWER" |
| 31 | + ;; |
| 32 | + esac |
| 33 | +
|
| 34 | + curl -H "Content-Type: application/json" \ |
| 35 | + -X POST \ |
| 36 | + -d "{\"content\": \"$DISCORD_MENTION 리뷰 요청이 왔어요! 👀\", \"embeds\": [{\"title\": \"#$PR_NUMBER $PR_TITLE\", \"url\": \"$PR_URL\", \"color\": 5814783}]}" \ |
| 37 | + $DISCORD_WEBHOOK |
| 38 | +
|
| 39 | + review-completed-notify: |
| 40 | + if: github.event_name == 'pull_request_review' |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: Send Review Completed Notification |
| 44 | + env: |
| 45 | + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 46 | + REVIEWER: ${{ github.event.review.user.login }} |
| 47 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 48 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 49 | + AUTHOR: ${{ github.event.pull_request.user.login }} |
| 50 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 51 | + REVIEW_STATE: ${{ github.event.review.state }} |
| 52 | + run: | |
| 53 | + case "$AUTHOR" in |
| 54 | + "chanho0908"|"JoungPeto0908") |
| 55 | + AUTHOR_MENTION="<@379613882001391626>" |
| 56 | + ;; |
| 57 | + "dogmania") |
| 58 | + AUTHOR_MENTION="<@951268632770531399>" |
| 59 | + ;; |
| 60 | + *) |
| 61 | + AUTHOR_MENTION="@$AUTHOR" |
| 62 | + ;; |
| 63 | + esac |
| 64 | +
|
| 65 | + case "$REVIEW_STATE" in |
| 66 | + "changes_requested") |
| 67 | + MESSAGE="수정 요청이 있습니다 🔧" |
| 68 | + COLOR=15158332 |
| 69 | + ;; |
| 70 | + "commented") |
| 71 | + MESSAGE="리뷰 코멘트가 달렸습니다 💬" |
| 72 | + COLOR=10181046 |
| 73 | + ;; |
| 74 | + *) |
| 75 | + MESSAGE="리뷰가 완료되었습니다 📝" |
| 76 | + COLOR=5814783 |
| 77 | + ;; |
| 78 | + esac |
| 79 | +
|
| 80 | + curl -H "Content-Type: application/json" \ |
| 81 | + -X POST \ |
| 82 | + -d "{\"content\": \"$AUTHOR_MENTION $MESSAGE\", \"embeds\": [{\"title\": \"#$PR_NUMBER $PR_TITLE\", \"url\": \"$PR_URL\", \"color\": $COLOR}]}" \ |
| 83 | + $DISCORD_WEBHOOK |
| 84 | +
|
| 85 | + merge-notify: |
| 86 | + if: github.event.pull_request.merged == true |
| 87 | + runs-on: ubuntu-latest |
| 88 | + steps: |
| 89 | + - name: Send Merge Notification |
| 90 | + env: |
| 91 | + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 92 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 93 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 94 | + AUTHOR: ${{ github.event.pull_request.user.login }} |
| 95 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 96 | + run: | |
| 97 | + case "$AUTHOR" in |
| 98 | + "chanho0908"|"JoungPeto0908") |
| 99 | + AUTHOR_MENTION="<@379613882001391626>" |
| 100 | + ;; |
| 101 | + "dogmania") |
| 102 | + AUTHOR_MENTION="<@951268632770531399>" |
| 103 | + ;; |
| 104 | + *) |
| 105 | + AUTHOR_MENTION="@$AUTHOR" |
| 106 | + ;; |
| 107 | + esac |
| 108 | +
|
| 109 | + curl -H "Content-Type: application/json" \ |
| 110 | + -X POST \ |
| 111 | + -d "{\"content\": \"🎉 PR이 머지되었습니다! $AUTHOR_MENTION\", \"embeds\": [{\"title\": \"#$PR_NUMBER $PR_TITLE\", \"url\": \"$PR_URL\", \"color\": 3066993}]}" \ |
| 112 | + $DISCORD_WEBHOOK |
0 commit comments