notify-discord.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #if: "contains(github.event.head_commit.message, '[skip ci]')"
  11. steps:
  12. - uses: actions/checkout@v3
  13. with:
  14. fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
  15. - name: Get changed files
  16. id: changed-files
  17. uses: tj-actions/changed-files@v34
  18. with:
  19. separator: "----------------------"
  20. - name: List all changed files
  21. run: |
  22. for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
  23. echo "$file was changed"
  24. done
  25. - uses: benjlevesque/short-sha@v2.1
  26. id: short-sha
  27. with:
  28. length: 7
  29. - run: echo $SHA
  30. env:
  31. SHA: ${{ steps.short-sha.outputs.sha }}
  32. - run: echo $SHA
  33. env:
  34. SHA: ${{ env.SHA }}
  35. - name: Discord notification
  36. env:
  37. DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
  38. DISCORD_AVATAR: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png'
  39. DISCORD_EMBEDS: '[ {
  40. "author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{github.actor}}" },
  41. "url": "https://github.com/${{github.repository}}/commit/${{github.sha}}",
  42. "fields": [
  43. { "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },
  44. { "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/tree/${{github.ref_name}})", "inline": true },
  45. { "name": "Event", "value": "${{github.event_name}}", "inline": true },
  46. { "name": "Job", "value": "${{github.job}}", "inline": true },
  47. { "name": "Commit Message", "value": "[${{ env.SHA }}](https://github.com/${{github.repository}}/commit/${{github.sha}}) - `${{github.event.head_commit.message}}`" },
  48. { "name": "Changed Files", "value": "${{ steps.changed-files.outputs.all_changed_files }}" },
  49. { "name": "Author", "value": "[${{github.event.head_commit.author.name}}](https://github.com/${{github.actor}})" }
  50. ],
  51. "color":1127128,
  52. "timestamp": "${{github.event.head_commit.timestamp}}",
  53. "footer":{"text": "${{github.event.head_commit.timestamp}}"}
  54. } ]'
  55. uses: Ilshidur/action-discord@master
  56. - name: echo
  57. run: |
  58. echo ${{github.event_name}}
  59. # https://stackoverflow.com/a/68068674/19395252
  60. # https://birdie0.github.io/discord-webhooks-guide/structure/embeds.html
  61. # https://github.com/marketplace/actions/changed-files