home-assistant-newt-addon/.github/workflows/discord-changelog.yml
Jørgen Ferdinand edac709a4b
Update discord-changelog.yml
Added role pinging
2025-05-21 17:55:08 +02:00

54 lines
1.4 KiB
YAML

name: Post Changelog to Discord
on:
push:
branches:
- main
paths:
- 'CHANGELOG.md'
jobs:
post_to_discord:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Extract latest changelog block
id: changelog
run: |
changelog_block=$(awk '
BEGIN { found=0 }
/^## 🔹 Version / {
if (found) exit;
found=1;
print $0;
next;
}
found {
if (/^## /) exit;
print $0;
}
' CHANGELOG.md)
# Escape for JSON
changelog_block=$(echo "$changelog_block" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
echo "BLOCK=$changelog_block" >> $GITHUB_OUTPUT
- name: Send to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_CHANGELOG_WEBHOOK }}
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d "{
\"content\": \"<@&1374737922980581436>\",
\"username\": \"Newt Changelog Bot\",
\"embeds\": [{
\"title\": \"📦 New Changelog Update\",
\"description\": \"${{ steps.changelog.outputs.BLOCK }}\",
\"color\": 7506394
}]
}" \
$DISCORD_WEBHOOK