notify-discord-issues.yml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. name: Discord Issue Notification
  2. on:
  3. issues:
  4. types: [opened, reopened, closed]
  5. jobs:
  6. Discord:
  7. runs-on: ubuntu-latest
  8. name: Discord Issue Notifier
  9. steps:
  10. - name: Determine action color and emoji
  11. id: action-info
  12. run: |
  13. case "${{ github.event.action }}" in
  14. "opened")
  15. echo "color=15158332" >> $GITHUB_OUTPUT # Red
  16. echo "emoji=🔴" >> $GITHUB_OUTPUT
  17. echo "action_text=Opened" >> $GITHUB_OUTPUT
  18. ;;
  19. "reopened")
  20. echo "color=16776960" >> $GITHUB_OUTPUT # Yellow
  21. echo "emoji=🟡" >> $GITHUB_OUTPUT
  22. echo "action_text=Reopened" >> $GITHUB_OUTPUT
  23. ;;
  24. "closed")
  25. echo "color=5763719" >> $GITHUB_OUTPUT # Green
  26. echo "emoji=🟢" >> $GITHUB_OUTPUT
  27. echo "action_text=Closed" >> $GITHUB_OUTPUT
  28. ;;
  29. esac
  30. - name: Create Discord webhook payload
  31. run: |
  32. # Create a temporary JSON file
  33. cat > discord_payload.json << 'EOF'
  34. {
  35. "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
  36. "embeds": [
  37. {
  38. "title": "${{ steps.action-info.outputs.emoji }} Issue ${{ steps.action-info.outputs.action_text }}: #${{ github.event.issue.number }}",
  39. "description": "${{ github.event.issue.title }}",
  40. "url": "${{ github.event.issue.html_url }}",
  41. "color": ${{ steps.action-info.outputs.color }},
  42. "thumbnail": {
  43. "url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
  44. },
  45. "fields": [
  46. {
  47. "name": "📋 Issue #",
  48. "value": "`#${{ github.event.issue.number }}`",
  49. "inline": true
  50. },
  51. {
  52. "name": "👤 Author",
  53. "value": "[${{ github.event.issue.user.login }}](${{ github.event.issue.user.html_url }})",
  54. "inline": true
  55. },
  56. {
  57. "name": "📁 Repository",
  58. "value": "[${{ github.event.repository.name }}](${{ github.event.repository.html_url }})",
  59. "inline": true
  60. },
  61. {
  62. "name": "🏷️ Labels",
  63. "value": "${{ github.event.issue.labels[0].name && join(github.event.issue.labels.*.name, ', ') || 'None' }}",
  64. "inline": true
  65. },
  66. {
  67. "name": "📊 State",
  68. "value": "`${{ github.event.issue.state }}`",
  69. "inline": true
  70. },
  71. {
  72. "name": "🔗 View Issue",
  73. "value": "[Issue Page](${{ github.event.issue.html_url }})",
  74. "inline": true
  75. }
  76. ],
  77. "timestamp": "${{ github.event.issue.created_at }}",
  78. "footer": {
  79. "text": "Workout Cool • Issue ${{ steps.action-info.outputs.action_text }}",
  80. "icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
  81. }
  82. }
  83. ]
  84. }
  85. EOF
  86. - name: Send Discord notification
  87. run: |
  88. curl -H "Content-Type: application/json" \
  89. -d @discord_payload.json \
  90. "${{ secrets.DISCORD_ISSUES_WEBHOOK }}"