Skip to content

Merge pull request #81 from VirtueSky/dev #5

Merge pull request #81 from VirtueSky/dev

Merge pull request #81 from VirtueSky/dev #5

# .github/workflows/notify-discord-release.yml
name: Notify Discord on Release
on:

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

View workflow run for this annotation

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

Invalid workflow file

You have an error in your yaml syntax on line 4
release:
types: [published]
jobs:
notify-discord:
runs-on: ubuntu-latest
steps:
- name: Send release info to Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
# Escape special characters in release notes
SAFE_NOTES="${{ github.event.release.body }}"
SAFE_NOTES="${SAFE_NOTES//\"/\\\"}"
SAFE_NOTES="${SAFE_NOTES//$'\n'/\\n}"
# Create timestamp
CREATED_AT="${{ github.event.release.created_at }}"
CREATED_AT="${CREATED_AT//T/ }"
CREATED_AT="${CREATED_AT//Z/ UTC}"
jq -n \
--arg title "${{ github.event.release.name }}" \
--arg tag "${{ github.event.release.tag_name }}" \
--arg url "${{ github.event.release.html_url }}" \
--arg author "${{ github.actor }}" \
--arg notes "$SAFE_NOTES" \
--arg created "$CREATED_AT" \
--arg repo "${{ github.repository }}" \
'{
username: "GitHub Release Bot",
avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
embeds: [
{
title: "🚀 New Release Published",
url: $url,
color: 5793266,
author: {
name: $author,
icon_url: ("https://github.com/" + $author + ".png")
},
fields: [
{name: "Repository", value: $repo, inline: true},
{name: "Tag", value: $tag, inline: true},
{name: "Released at", value: $created, inline: false},
{name: "Release Notes", value: (if $notes == "" then "No description" else $notes end), inline: false}
],
footer: {
text: "GitHub Actions",
icon_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
},
timestamp: (now | todate)
}
]
}' > payload.json
curl -H "Content-Type: application/json" \
-X POST \
-d @payload.json \
"$DISCORD_WEBHOOK_URL"