Notify Discord on Release #6
Workflow file for this run
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
name: Discord Notification on Release | |
on: | |
release: | |
types: [created] | |
jobs: | |
notify_discord: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send Release Notification to Discord | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
RELEASE_NAME: ${{ github.event.release.name }} | |
RELEASE_BODY: ${{ github.event.release.body }} | |
run: | | |
# Using jq to safely encode JSON strings | |
JSON_PAYLOAD=$(jq -n \ | |
--arg content "**Release:** $RELEASE_NAME\n$RELEASE_BODY" \ | |
'{username: "GitHub Release Bot", content: $content}') | |
# Sending the message to Discord | |
curl -H "Content-Type: application/json" \ | |
-d "$JSON_PAYLOAD" \ | |
$DISCORD_WEBHOOK |