action.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. name: 'Slack Notification'
  2. description: 'Send Slack notification for workflow failures'
  3. inputs:
  4. webhook-url:
  5. description: 'Slack webhook URL'
  6. required: true
  7. channel:
  8. description: 'Slack channel to notify'
  9. required: true
  10. workflow-name:
  11. description: 'Name of the workflow'
  12. required: true
  13. failed-jobs:
  14. description: 'JSON object containing job results'
  15. required: true
  16. runs:
  17. using: 'composite'
  18. steps:
  19. - name: Parse failed jobs
  20. id: parse-jobs
  21. shell: bash
  22. run: |
  23. echo "Parsing job results..."
  24. failed_list=""
  25. echo '${{ inputs.failed-jobs }}' | jq -r 'to_entries[] | select(.value.result == "failure") | .key' | while read job; do
  26. case $job in
  27. "check-translations") failed_list="${failed_list}❌ Translation check\n" ;;
  28. "knip") failed_list="${failed_list}❌ Knip analysis\n" ;;
  29. "compile") failed_list="${failed_list}❌ Compile & lint\n" ;;
  30. "unit-test") failed_list="${failed_list}❌ Unit tests\n" ;;
  31. "integration-test") failed_list="${failed_list}❌ Integration tests\n" ;;
  32. esac
  33. done
  34. echo "failed_jobs<<EOF" >> $GITHUB_OUTPUT
  35. echo -e "$failed_list" | sed '/^$/d' >> $GITHUB_OUTPUT
  36. echo "EOF" >> $GITHUB_OUTPUT
  37. - name: Send Slack notification
  38. uses: 8398a7/action-slack@v3
  39. with:
  40. status: failure
  41. channel: ${{ inputs.channel }}
  42. text: |
  43. 🚨 ${{ inputs.workflow-name }} workflow failed on main branch!
  44. Repository: ${{ github.repository }}
  45. Commit: ${{ github.sha }}
  46. Author: ${{ github.actor }}
  47. Failed jobs:
  48. ${{ steps.parse-jobs.outputs.failed_jobs }}
  49. View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  50. env:
  51. SLACK_WEBHOOK_URL: ${{ inputs.webhook-url }}