Skip to content

Commit 7976aaa

Browse files
authored
ci: update slack failed message in release-nightly workflow (#844)
1 parent 1211386 commit 7976aaa

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

.github/workflows/release-nightly.yml

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
name: Release
1616
runs-on: ubuntu-24.04
1717
strategy:
18+
fail-fast: true
1819
matrix:
1920
release:
2021
- release-all-in-one-nightly
@@ -47,13 +48,59 @@ jobs:
4748
slack-notify-failure:
4849
needs: release
4950
runs-on: ubuntu-24.04
50-
if: failure()
51+
if: failure() && always()
5152
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
56+
- name: Get failed jobs
57+
id: get_failed_jobs
58+
uses: actions/github-script@v7
59+
with:
60+
github-token: ${{ secrets.GITHUB_TOKEN }}
61+
script: |
62+
const response = await github.rest.actions.listJobsForWorkflowRun({
63+
owner: context.repo.owner,
64+
repo: context.repo.repo,
65+
run_id: context.runId
66+
});
67+
68+
const failedJobs = response.data.jobs
69+
.filter(job => job.status === 'completed' && job.conclusion === 'failure')
70+
.map(job => job.name)
71+
.join(', ');
72+
73+
core.setOutput('failed_jobs', failedJobs);
74+
5275
- name: Slack Notification
5376
uses: 8398a7/action-slack@v3
5477
with:
55-
status: ${{ job.status }}
56-
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest # selectable (default: repo,message)
78+
status: custom
79+
fields: repo,workflow,commit,author
80+
custom_payload: |
81+
{
82+
"text": "Release Nightly Failed 😔",
83+
"attachments": [{
84+
"color": "danger",
85+
"fields": [
86+
{
87+
"title": "Failed Build",
88+
"value": "${{ steps.get_failed_jobs.outputs.failed_jobs }}",
89+
"short": false
90+
},
91+
{
92+
"title": "Commit",
93+
"value": "<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>",
94+
"short": false
95+
},
96+
{
97+
"title": "Author",
98+
"value": "${{ github.actor }}",
99+
"short": true
100+
}
101+
]
102+
}]
103+
}
57104
env:
58105
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_ENG_NOTIFS }}
59106
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)