This repository was archived by the owner on Jun 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (130 loc) · 5.93 KB
/
Copy pathdiscord-pr-notifications.yml
File metadata and controls
143 lines (130 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: 🔔 Discord PR Notifications
on:
pull_request:
types: [opened, reopened, closed, ready_for_review]
pull_request_review:
types: [submitted]
permissions:
contents: read
pull-requests: read
jobs:
# ================================
# Discord PR Notifications
# ================================
notify-discord:
name: Send Discord Notification
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Determine PR action details
id: pr_action
run: |
case "${{ github.event.action }}" in
"opened")
echo "color=3447003" >> $GITHUB_OUTPUT
echo "emoji=🆕" >> $GITHUB_OUTPUT
echo "text=opened" >> $GITHUB_OUTPUT
;;
"reopened")
echo "color=16776960" >> $GITHUB_OUTPUT
echo "emoji=🔄" >> $GITHUB_OUTPUT
echo "text=reopened" >> $GITHUB_OUTPUT
;;
"closed")
if [ "${{ github.event.pull_request.merged }}" == "true" ]; then
echo "color=65280" >> $GITHUB_OUTPUT
echo "emoji=✅" >> $GITHUB_OUTPUT
echo "text=merged" >> $GITHUB_OUTPUT
else
echo "color=16711680" >> $GITHUB_OUTPUT
echo "emoji=❌" >> $GITHUB_OUTPUT
echo "text=closed" >> $GITHUB_OUTPUT
fi
;;
"ready_for_review")
echo "color=3447003" >> $GITHUB_OUTPUT
echo "emoji=👀" >> $GITHUB_OUTPUT
echo "text=marked as ready for review" >> $GITHUB_OUTPUT
;;
*)
echo "color=9936031" >> $GITHUB_OUTPUT
echo "emoji=📝" >> $GITHUB_OUTPUT
echo "text=${{ github.event.action }}" >> $GITHUB_OUTPUT
;;
esac
- name: Extract commit SHA
id: commit
run: |
SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7)
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
- name: Send Discord notification
uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: "GitHub Actions"
avatar-url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
embed-title: "${{ steps.pr_action.outputs.emoji }} Pull Request ${{ steps.pr_action.outputs.text }}"
embed-description: |
**PR #${{ github.event.pull_request.number }}**: ${{ github.event.pull_request.title }}
🌿 Branch: \`${{ github.event.pull_request.head.ref }}\` → \`${{ github.event.pull_request.base.ref }}\`
👤 Author: [${{ github.event.pull_request.user.login }}](${{ github.event.pull_request.user.html_url }})
📊 Changes: +${{ github.event.pull_request.additions }} -${{ github.event.pull_request.deletions }}
📦 Commit: \`${{ steps.commit.outputs.short_sha }}\`
[View Pull Request →](${{ github.event.pull_request.html_url }})
embed-url: ${{ github.event.pull_request.html_url }}
embed-color: ${{ steps.pr_action.outputs.color }}
embed-thumbnail-url: ${{ github.event.pull_request.user.avatar_url }}
embed-footer-text: "Homepedia"
embed-footer-icon-url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
embed-timestamp: ${{ github.event.pull_request.created_at }}
# ================================
# Review notifications
# ================================
notify-review:
name: Send Review Notification
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_review'
steps:
- name: Determine review details
id: review_action
run: |
case "${{ github.event.review.state }}" in
"approved")
echo "color=65280" >> $GITHUB_OUTPUT
echo "emoji=✅" >> $GITHUB_OUTPUT
echo "text=approved" >> $GITHUB_OUTPUT
;;
"changes_requested")
echo "color=16711680" >> $GITHUB_OUTPUT
echo "emoji=❌" >> $GITHUB_OUTPUT
echo "text=requested changes" >> $GITHUB_OUTPUT
;;
"commented")
echo "color=9936031" >> $GITHUB_OUTPUT
echo "emoji=💬" >> $GITHUB_OUTPUT
echo "text=commented" >> $GITHUB_OUTPUT
;;
*)
echo "color=9936031" >> $GITHUB_OUTPUT
echo "emoji=📝" >> $GITHUB_OUTPUT
echo "text=${{ github.event.review.state }}" >> $GITHUB_OUTPUT
;;
esac
- name: Send review notification
uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: "GitHub Actions"
avatar-url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
embed-title: "${{ steps.review_action.outputs.emoji }} PR Review ${{ steps.review_action.outputs.text }}"
embed-description: |
**PR #${{ github.event.pull_request.number }}**: ${{ github.event.pull_request.title }}
👤 Reviewer: [${{ github.event.review.user.login }}](${{ github.event.review.user.html_url }})
👤 Author: [${{ github.event.pull_request.user.login }}](${{ github.event.pull_request.user.html_url }})
[View Review →](${{ github.event.review.html_url }})
embed-url: ${{ github.event.review.html_url }}
embed-color: ${{ steps.review_action.outputs.color }}
embed-thumbnail-url: ${{ github.event.review.user.avatar_url }}
embed-footer-text: "Homepedia"
embed-footer-icon-url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
embed-timestamp: ${{ github.event.review.submitted_at }}