-
Notifications
You must be signed in to change notification settings - Fork 3
39 lines (34 loc) · 1.19 KB
/
webhook.yml
File metadata and controls
39 lines (34 loc) · 1.19 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
name: Discord release webhook
on:
release:
types: [published]
permissions:
contents: read
jobs:
notify:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Determine mention role
id: mention
env:
TAG: ${{ github.event.release.tag_name }}
run: |
if [[ "$TAG" == *canary* ]]; then
echo "role=<@&1481870465416040471>" >> "$GITHUB_OUTPUT"
else
echo "role=<@&1481870405156212756>" >> "$GITHUB_OUTPUT"
fi
- name: Post release message to Discord
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
RELEASE_NAME: ${{ github.event.release.name }}
RELEASE_BODY: ${{ github.event.release.body }}
RELEASE_URL: ${{ github.event.release.html_url }}
MENTION_ROLE: ${{ steps.mention.outputs.role }}
run: |
payload=$(jq -n --arg name "$RELEASE_NAME" --arg body "$RELEASE_BODY" --arg url "$RELEASE_URL" --arg role "$MENTION_ROLE" '{content: ($role + "\n# " + $name + "\n" + $body + "\n\n-# " + $url)}')
curl -sS -X POST \
-H "Content-Type: application/json" \
-d "$payload" \
"$WEBHOOK_URL"