Skip to content

Commit 80aab84

Browse files
committed
fix(repo): add Slack notification recovery for failed release publishes
1 parent 9a6a63f commit 80aab84

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ jobs:
121121
# scenario by checking npm for the local package version and dispatches
122122
# if the packages are already live.
123123
- name: Recover downstream notifications
124+
id: recover
124125
if: always() && steps.changesets.conclusion == 'failure'
125126
uses: actions/github-script@v7
126127
with:
@@ -196,14 +197,37 @@ jobs:
196197
await Promise.all(dispatches);
197198
core.notice('Recovery dispatch completed successfully');
198199
200+
// Build publishedPackages list for Slack notification recovery
201+
const fs = require('fs');
202+
const path = require('path');
203+
const packagesDir = './packages';
204+
const publishedPackages = [];
205+
for (const dir of fs.readdirSync(packagesDir, { withFileTypes: true })) {
206+
if (!dir.isDirectory()) continue;
207+
const pkgPath = path.join(packagesDir, dir.name, 'package.json');
208+
if (!fs.existsSync(pkgPath)) continue;
209+
const { name, version, private: isPrivate } = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
210+
if (isPrivate || version.includes('-')) continue;
211+
if (isPublished(name, version)) {
212+
publishedPackages.push({ name, version });
213+
}
214+
}
215+
216+
if (publishedPackages.length > 0) {
217+
core.setOutput('publishedPackages', JSON.stringify(publishedPackages));
218+
core.notice(`Recovery: found ${publishedPackages.length} published packages for Slack notification`);
219+
}
220+
199221
- name: Generate notification payload
200222
id: notification
201-
if: steps.changesets.outputs.published == 'true'
202-
run: payload=$(node scripts/notify.mjs '${{ steps.changesets.outputs.publishedPackages }}' '${{ github.actor }}') && echo ::set-output name=payload::${payload//$'\n'/'%0A'}
223+
if: always() && (steps.changesets.outputs.published == 'true' || steps.recover.outputs.publishedPackages)
224+
run: |
225+
PACKAGES='${{ steps.changesets.outputs.publishedPackages || steps.recover.outputs.publishedPackages }}'
226+
payload=$(node scripts/notify.mjs "$PACKAGES" '${{ github.actor }}') && echo ::set-output name=payload::${payload//$'\n'/'%0A'}
203227
204228
- name: Send commit log to Slack
205229
id: slack
206-
if: steps.changesets.outputs.published == 'true'
230+
if: always() && (steps.changesets.outputs.published == 'true' || steps.recover.outputs.publishedPackages)
207231
uses: slackapi/slack-github-action@v1.24.0
208232
with:
209233
payload: ${{ steps.notification.outputs.payload }}

0 commit comments

Comments
 (0)