Skip to content

Commit a897d20

Browse files
ci: make the release failure alert resilient to missing DEPLOYMENT_STATUS (#11422)
* ci: make the release failure alert resilient to missing `DEPLOYMENT_STATUS` If the npm release fails then the non-npm release is not even attempted. In which case the `DEPLOYMENT_STATUS` is empty, which was causing the JSON parsing to fail and no alert to be sent. * Apply suggestion from @edmundhung --------- Co-authored-by: Edmund Hung <edmund@cloudflare.com>
1 parent 326d140 commit a897d20

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tools/deployments/alert-on-error.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@ if (require.main === module) {
77
details: "Packages failed to publish",
88
});
99
}
10-
const deploymentStatus = JSON.parse(process.env.DEPLOYMENT_STATUS as string);
1110

12-
for (const [pkg, err] of Object.entries(deploymentStatus)) {
13-
status.push({
14-
label: pkg,
15-
details: err,
16-
});
11+
if (process.env.DEPLOYMENT_STATUS) {
12+
try {
13+
const deploymentStatus = JSON.parse(
14+
process.env.DEPLOYMENT_STATUS as string
15+
);
16+
17+
for (const [pkg, err] of Object.entries(deploymentStatus)) {
18+
status.push({
19+
label: pkg,
20+
details: err,
21+
});
22+
}
23+
} catch (e) {
24+
status.push({
25+
label: "Deployment status",
26+
details: `Failed to parse deployment status: ${e}. Received: "${process.env.DEPLOYMENT_STATUS}"`,
27+
});
28+
}
1729
}
1830

1931
if (status.length > 0) {

0 commit comments

Comments
 (0)