Skip to content

Commit 7a75126

Browse files
authored
chore(ci): slack notification on release failure (#1605)
1 parent a6dfbb6 commit 7a75126

File tree

3 files changed

+96
-12
lines changed

3 files changed

+96
-12
lines changed

.github/workflows/label-issues.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ jobs:
3232
};
3333
3434
let labels = [];
35-
if (context.payload.action === 'transferred') {
36-
// Label based on source repository
37-
const sourceRepo = context.payload.changes?.old_repository?.full_name || context.payload.changes?.from?.full_name || context.payload.changes?.new_repository?.full_name;
38-
const label = labelMap[sourceRepo];
39-
if (label) labels.push(label);
40-
} else if (context.payload.action === 'opened') {
35+
36+
const oldRepoFullName = context.payload.changes?.old_repository?.full_name;
37+
if (oldRepoFullName) {
38+
const fullNameLower = (oldRepoFullName || '').toLowerCase();
39+
const shortName = fullNameLower.split('/')?.[1];
40+
console.log('old_repository', fullNameLower, shortName);
41+
const transferLabel = labelMap[fullNameLower] || labelMap[shortName];
42+
if (transferLabel) labels.push(transferLabel);
43+
} else {
4144
// Label based on "Library affected" field in the issue body
4245
const body = context.payload.issue.body || '';
4346
const match = body.match(/### Library affected\s*\n+([\s\S]*?)(\n###|\n$)/i);
@@ -49,12 +52,11 @@ jobs:
4952
if (labelMap[lib]) labels.push(labelMap[lib]);
5053
}
5154
}
52-
}
53-
54-
// Check the title for "[migration]"
55-
const title = context.payload.issue.title || '';
56-
if (title.toLowerCase().includes('[migration]')) {
57-
labels.push('migration');
55+
// Check the title for "[migration]"
56+
const title = context.payload.issue.title || '';
57+
if (title.toLowerCase().includes('[migration]')) {
58+
labels.push('migration');
59+
}
5860
}
5961
6062
// Remove duplicates

.github/workflows/publish.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
npm run release-stable -- --versionSpecifier "${{ github.event.inputs.version_specifier }}"
104104
105105
- name: Summary
106+
if: ${{ success() }}
106107
run: |
107108
echo "## ✅ Stable Release" >> $GITHUB_STEP_SUMMARY
108109
echo "- **Version specifier:** \`${{ github.event.inputs.version_specifier }}\`" >> $GITHUB_STEP_SUMMARY
@@ -263,3 +264,20 @@ jobs:
263264
env:
264265
NPM_CONFIG_PROVENANCE: true
265266
RELEASE_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} # used for tags
267+
notify-stable-failure:
268+
name: Notify Slack for Stable failure
269+
needs: release-stable
270+
if: ${{ always() && github.event_name == 'workflow_dispatch' && needs.release-stable.result == 'failure' }}
271+
uses: ./.github/workflows/slack-notify.yml
272+
secrets: inherit
273+
with:
274+
subject: 'Stable Release'
275+
276+
notify-canary-failure:
277+
name: Notify Slack for Canary failure
278+
needs: release-canary
279+
if: ${{ always() && github.event_name == 'push' && needs.release-canary.result == 'failure' }}
280+
uses: ./.github/workflows/slack-notify.yml
281+
secrets: inherit
282+
with:
283+
subject: 'Canary Release'

.github/workflows/slack-notify.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Reusable Slack Notification
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
subject:
7+
description: 'Short subject describing what failed (e.g., Canary Release)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
notify:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Send Slack notification
16+
run: |
17+
payload=$(cat <<EOF
18+
{
19+
"text": "❌ ${{ inputs.subject }} failed in ${{ github.repository }}",
20+
"blocks": [
21+
{
22+
"type": "header",
23+
"text": { "type": "plain_text", "text": "❌ ${{ inputs.subject }} failed", "emoji": true }
24+
},
25+
{
26+
"type": "section",
27+
"text": { "type": "mrkdwn", "text": "The workflow run failed. See details below. @group-client-libs" }
28+
},
29+
{
30+
"type": "section",
31+
"fields": [
32+
{ "type": "mrkdwn", "text": "*Repository*\n${{ github.repository }}" },
33+
{ "type": "mrkdwn", "text": "*Workflow*\n${{ github.workflow }}" },
34+
{ "type": "mrkdwn", "text": "*Ref*\n${{ github.ref_name }}" },
35+
{ "type": "mrkdwn", "text": "*Actor*\n${{ github.actor }}" }
36+
]
37+
},
38+
{
39+
"type": "actions",
40+
"elements": [
41+
{
42+
"type": "button",
43+
"text": { "type": "plain_text", "text": "View Run" },
44+
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
45+
},
46+
{
47+
"type": "button",
48+
"text": { "type": "plain_text", "text": "View Commit" },
49+
"url": "https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
50+
}
51+
]
52+
},
53+
{
54+
"type": "context",
55+
"elements": [
56+
{ "type": "mrkdwn", "text": "Commit: ${{ github.sha }}" }
57+
]
58+
}
59+
]
60+
}
61+
EOF
62+
)
63+
64+
curl -X POST -H 'Content-type: application/json' --data "$payload" ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}

0 commit comments

Comments
 (0)