File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Notify Slack on Failure
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ context_title :
7+ required : true
8+ type : string
9+ description : The context title (e.g., "PR # 123: Title" or "main branch")
10+ failed_job_name :
11+ required : true
12+ type : string
13+ description : The name of the failed job
14+ secrets :
15+ SLACK_WEBHOOK_URL :
16+ required : true
17+
18+ jobs :
19+ notify-slack :
20+ runs-on : ubuntu-latest
21+ steps :
22+ - name : Send Slack Notification
23+ 24+ with :
25+ webhook : ${{ secrets.SLACK_WEBHOOK_URL }}
26+ webhook-type : incoming-webhook
27+
28+ payload : |
29+ text: "@channel CI failed on ${{ inputs.context_title }}"
30+ blocks:
31+ - type: "section"
32+ text:
33+ type: "mrkdwn"
34+ text: "<!channel> :rotating_light: *CI FAILED on ${{ inputs.context_title }}*"
35+
36+ - type: "section"
37+ fields:
38+ - type: "mrkdwn"
39+ text: "*Workflow:*\n`${{ github.workflow }}`"
40+ - type: "mrkdwn"
41+ text: "*Failed Job:*\n`${{ inputs.failed_job_name }}`"
42+ - type: "mrkdwn"
43+ text: "*Commit:*\n`${{ github.sha }}`"
44+ - type: "mrkdwn"
45+ text: "*Author:*\n`${{ github.actor }}`"
46+
47+ - type: "section"
48+ text:
49+ type: "mrkdwn"
50+ text: "<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View failed job run>"
51+
Original file line number Diff line number Diff line change 99 test :
1010 uses : ./.github/workflows/test.yaml
1111 secrets : inherit
12+
13+ notify-slack :
14+ needs : test
15+ if : failure()
16+ uses : ./.github/workflows/notify-slack.yaml
17+ with :
18+ context_title : " main branch"
19+ failed_job_name : " test"
20+ secrets : inherit
You can’t perform that action at this time.
0 commit comments