Skip to content

Commit

Permalink
Update discord_notify.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
afreakyelf authored Apr 2, 2024
1 parent 0400af1 commit c7353b4
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions .github/workflows/discord_notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ 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
- name: Send Release Notification to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# Environment variables for release details
RELEASE_NAME: ${{ github.event.release.name }}
RELEASE_BODY: ${{ github.event.release.body }}
run: |
# Prepare the message content, preserving newlines
MESSAGE_CONTENT=$(echo -e "Release: $RELEASE_NAME\n$RELEASE_BODY")
# Using jq to create the JSON payload with actual newlines
JSON_PAYLOAD=$(jq --null-input \
--arg content "$MESSAGE_CONTENT" \
'{username: "GitHub Release Bot", content: $content}')
# Sending the message to Discord
curl -H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
$DISCORD_WEBHOOK

0 comments on commit c7353b4

Please sign in to comment.