-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsend-release-note-to-discord.yml
More file actions
39 lines (30 loc) · 1.37 KB
/
send-release-note-to-discord.yml
File metadata and controls
39 lines (30 loc) · 1.37 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: Send Release Notes to Discord
on:
release:
types: [published]
jobs:
send-discord-message:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Debug - Check GITHUB_EVENT_PATH
run: cat $GITHUB_EVENT_PATH
- name: Send release notes to Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
# Extract the release title, body, and URL from the event payload JSON file
RELEASE_TITLE=$(jq -r '.release.name' $GITHUB_EVENT_PATH)
RELEASE_NOTES=$(jq -r '.release.body' $GITHUB_EVENT_PATH)
RELEASE_URL=$(jq -r '.release.html_url' $GITHUB_EVENT_PATH)
# Debugging: Print the extracted values
echo "Release Title: $RELEASE_TITLE"
echo "Release Notes: $RELEASE_NOTES"
echo "Release URL: $RELEASE_URL"
# Create a simple JSON payload to send to Discord
PAYLOAD=$(jq -n --arg title "$RELEASE_TITLE" --arg notes "$RELEASE_NOTES" --arg url "$RELEASE_URL" '{content: "New Release: \($title)\n\n\($notes)\n\n[View Release](\($url))"}')
# Debugging: Print the payload
echo "Payload: $PAYLOAD"
# Send the payload to Discord using the webhook URL
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" "$DISCORD_WEBHOOK_URL"