-
Notifications
You must be signed in to change notification settings - Fork 29
39 lines (33 loc) · 1.75 KB
/
message-discord.yaml
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
name: Notify Discord on PR Events
on:
pull_request:
types: [opened, closed]
jobs:
notify-discord:
runs-on: ubuntu-latest
steps:
- name: Send Discord notification
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
if [[ "${{ github.event.action }}" == "opened" ]]; then
MESSAGE="📢 A new pull request has been opened in \`${{ github.repository }}\`"
MESSAGE+=" by \`${{ github.actor }}\`.\n"
MESSAGE+="🔗 [PR #${{ github.event.number }} - ${{ github.event.pull_request.title }}]"
MESSAGE+="(${{ github.event.pull_request.html_url }})"
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true" ]]; then
MESSAGE="✅ Pull request \`${{ github.event.pull_request.title }}\` in \`${{ github.repository }}\`"
MESSAGE+=" has been merged by \`${{ github.actor }}\`.\n"
MESSAGE+="🔗 [PR #${{ github.event.number }}]"
MESSAGE+="(${{ github.event.pull_request.html_url }})"
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" != "true" ]]; then
MESSAGE="❌ Pull request \`${{ github.event.pull_request.title }}\` in \`${{ github.repository }}\`"
MESSAGE+=" has been closed without merging by \`${{ github.actor }}\`.\n"
MESSAGE+="🔗 [PR #${{ github.event.number }}]"
MESSAGE+="(${{ github.event.pull_request.html_url }})"
else
exit 0; # Exit for any other PR events (not interested)
fi
curl -H "Content-Type: application/json" \
-d "{\"content\": \"$MESSAGE\"}" \
$DISCORD_WEBHOOK_URL