try again #13
This file contains hidden or 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: Send message to Discord | ||
| env: | ||
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | ||
| run: | | ||
| # Install jq if it's not already available | ||
| sudo apt-get install -y jq | ||
| # Extract release details | ||
| RELEASE_NAME="${{ github.event.release.name }}" | ||
| RELEASE_BODY="${{ github.event.release.body }}" | ||
| RELEASE_URL="${{ github.event.release.html_url }}" | ||
| # Get the URL of the attachment (first mod file) | ||
| ATTACHMENT_URL=$(echo '${{ toJson(github.event.release.assets) }}' | jq -r '.[] | select(.name | contains("mod")) | .browser_download_url' | head -n 1) | ||
| # Escape special characters in the release body | ||
| ESCAPED_BODY=$(printf '%s' "$RELEASE_BODY" | jq -R '.') | ||
| # Construct the message payload | ||
| MESSAGE=$(jq -n \ | ||
| --arg name "$RELEASE_NAME" \ | ||
| --arg body "$ESCAPED_BODY" \ | ||
| --arg url "$RELEASE_URL" \ | ||
| --arg attachment "$ATTACHMENT_URL" \ | ||
| '{ | ||
| content: "@everyone A new update has been released!\n\n**\($name)**\n\n\($body)\n\n[Download Attachment](\($attachment))\n\n[Release URL](\($url))" | ||
| }') | ||
| # Send the message to Discord | ||
| curl -X POST $DISCORD_WEBHOOK_URL \ | ||
| -H "Content-Type: application/json" \ | ||
| -d "$MESSAGE" | ||