-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from ionet-official/discord_notifications
Feat: Send Release Note to Discord
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" |