notify-discord.yml 2.7 KB

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