notify-discord.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. name: Discord Notification
  2. on:
  3. release:
  4. types: [published]
  5. workflow_dispatch:
  6. jobs:
  7. Discord:
  8. runs-on: ubuntu-latest
  9. name: Discord Notifier
  10. steps:
  11. - uses: actions/checkout@v4
  12. with:
  13. fetch-depth: 0
  14. - name: Get previous release
  15. id: previous-release
  16. run: |
  17. PREV_TAG=$(git tag --sort=-version:refname | grep -v '${{ github.event.release.tag_name }}' | head -n1)
  18. echo "previous_tag=${PREV_TAG}" >> $GITHUB_OUTPUT
  19. - name: Get changed files since last release
  20. id: changed-files
  21. uses: tj-actions/changed-files@v44
  22. with:
  23. base_sha: ${{ steps.previous-release.outputs.previous_tag }}
  24. separator: "\n• "
  25. - name: Discord notification
  26. env:
  27. DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
  28. DISCORD_AVATAR: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png'
  29. DISCORD_EMBEDS: '[{
  30. "title": "🚀 New Release: ${{ github.event.release.tag_name }}",
  31. "description": "${{ github.event.release.name }}\n\n${{ github.event.release.body }}",
  32. "url": "${{ github.event.release.html_url }}",
  33. "color": 5763719,
  34. "thumbnail": {
  35. "url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
  36. },
  37. "fields": [
  38. { "name": "📦 Version", "value": "`${{ github.event.release.tag_name }}`", "inline": true },
  39. { "name": "👤 Released by", "value": "[${{ github.event.release.author.login }}](${{ github.event.release.author.html_url }})", "inline": true },
  40. { "name": "📁 Repository", "value": "[${{ github.event.repository.name }}](${{ github.event.repository.html_url }})", "inline": true },
  41. { "name": "🔗 Download", "value": "[Release Page](${{ github.event.release.html_url }})", "inline": true },
  42. { "name": "📝 Files Changed", "value": "• ${{ steps.changed-files.outputs.all_changed_files }}", "inline": false }
  43. ],
  44. "timestamp": "${{ github.event.release.published_at }}",
  45. "footer": {
  46. "text": "Workout Cool • Release",
  47. "icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
  48. }
  49. }]'
  50. uses: Ilshidur/action-discord@master
  51. # https://stackoverflow.com/a/68068674/19395252
  52. # https://birdie0.github.io/discord-webhooks-guide/structure/embeds.html
  53. # https://github.com/marketplace/actions/changed-files