Skip to content

try again

try again #13

- name: Send message to Discord

Check failure on line 1 in .github/workflows/discord-notify.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/discord-notify.yml

Invalid workflow file

You have an error in your yaml syntax on line 1
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"