Skip to content

Commit 725acb0

Browse files
committed
ci: update slack failed message in release-nightly workflow
1 parent 1211386 commit 725acb0

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

.github/workflows/release-nightly.yml

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Release Nightly
22
on:
33
push:
44
branches: [v2]
5+
pull_request:
6+
branches: [v2]
57
concurrency:
68
group: ${{ github.workflow }}-${{ github.ref }}
79
cancel-in-progress: true
@@ -15,6 +17,7 @@ jobs:
1517
name: Release
1618
runs-on: ubuntu-24.04
1719
strategy:
20+
fail-fast: true
1821
matrix:
1922
release:
2023
- release-all-in-one-nightly
@@ -47,13 +50,59 @@ jobs:
4750
slack-notify-failure:
4851
needs: release
4952
runs-on: ubuntu-24.04
50-
if: failure()
53+
if: failure() && always()
5154
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Get failed jobs
59+
id: get_failed_jobs
60+
uses: actions/github-script@v7
61+
with:
62+
github-token: ${{ secrets.GITHUB_TOKEN }}
63+
script: |
64+
const response = await github.rest.actions.listJobsForWorkflowRun({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
run_id: context.runId
68+
});
69+
70+
const failedJobs = response.data.jobs
71+
.filter(job => job.status === 'completed' && job.conclusion === 'failure')
72+
.map(job => job.name)
73+
.join(', ');
74+
75+
core.setOutput('failed_jobs', failedJobs);
76+
5277
- name: Slack Notification
5378
uses: 8398a7/action-slack@v3
5479
with:
55-
status: ${{ job.status }}
56-
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest # selectable (default: repo,message)
80+
status: custom
81+
fields: repo,workflow,commit,author
82+
custom_payload: |
83+
{
84+
"text": "Release Nightly Failed 😔",
85+
"attachments": [{
86+
"color": "danger",
87+
"fields": [
88+
{
89+
"title": "Failed Build",
90+
"value": "${{ steps.get_failed_jobs.outputs.failed_jobs }}",
91+
"short": false
92+
},
93+
{
94+
"title": "Commit",
95+
"value": "<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>",
96+
"short": false
97+
},
98+
{
99+
"title": "Author",
100+
"value": "${{ github.actor }}",
101+
"short": true
102+
}
103+
]
104+
}]
105+
}
57106
env:
58107
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_ENG_NOTIFS }}
59108
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)