feat(alerts): deploy lifecycle alerts (start/end/fail) via ANS - #1474
Merged
Conversation
- Add notifyDeploy() async helper to scripts/deploy-mta.cjs: best-effort
POST to ${cfg.srvUrl}/ops/deploy-event with Bearer auth, 5s AbortController
timeout, never throws, no new npm deps (native fetch + AbortController).
- Wire deployVersion (from writeVersionFile or readMtaVersion on --skip-build)
and fire at: start (before cf deploy), fail (cf deploy failure + smoke gate
failure), end (after smoke passes). Blue-green paused path logs a warn that
no auto "end" will fire.
- Guard require.main === module so tests can require() without running main().
- Export { notifyDeploy } for the test seam.
- Add scripts/__tests__/notify-deploy.test.js (3 tests: POST payload+auth,
network-error never-rejects, no-op when apiKey absent).
- Fix vitest.config.ts unit project include patterns to match .test.js
(was .test.ts only for scripts/__tests__/) and add globals:true so CJS
test files get describe/it/expect/vi injected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds automatic team notifications when a PROD (and dev/qa) deploy starts, finishes, or fails, reusing the SAP Alert Notification (ANS) plumbing wired yesterday (
@sap-tutorials/cds-alert-notification).Why
Deploys were silent — the operator watched a terminal and nobody else knew. This surfaces each deploy lifecycle boundary as a push notification.
How
The ANS credentials are bound to the
tutorials-srvCF app, butscripts/deploy-mta.cjsruns off-platform (workstation/CI) with no ANS binding. So the srv exposes an endpoint the deploy script pings:POST /ops/deploy-event(new,srv/routes/deploy-events.js) — bearer-guarded by the existingcontentAuthMiddleware(reusesCONTENT_API_KEY). Maps{phase, env, version, detail}→alerting.raise(...). Fail-open: always202on a valid phase,400on a bad one; never blocks a deploy.scripts/deploy-mta.cjs— newnotifyDeploy()helper (nativefetch, 5s timeout, never throws, never changes exit code) fired at three boundaries for all envs:start(beforecf deploy),end(after the smoke gate passes),fail(oncf deployor smoke-gate failure).package.json— registersDeployStarted/DeployFinished/DeployFailedeventTypes + a dedicatedemail:devrel-deployschannel.Routing
DeployStarted/DeployFinished→ severityNOTICE→email:devrel-deploysonly.DeployFailed→ severityERROR→email:devrel-deploysandemail:devrel-oncall(on-call should hear failed deploys).Post-merge / operator TODO (not in this PR)
devrel-deploysemail action in ANS with the real distribution-list address (same pattern asdevrel-oncall).ChatSettings.alertsEnabledON in the target env(s) via/admin-ui(default OFF).CONTENT_API_KEYmust be present in the deploy env (it already is for content publish).Caveats
--strategy blue-greendeploy pauses before the traffic swap and exits, so it emitsstartand (on failure)fail, but not an automaticfinished— documented in the runbook + a warn line. Accepted for v1.alertsEnabledcan suppress its own end/fail ping.Testing
notifyDeploybearer/never-reject/no-op, routing config) — all green..deploy/mta.yamlminor version bump 1.10.0 → 1.11.0.Spec:
docs/superpowers/specs/2026-08-04-deploy-lifecycle-alerts-design.mdPlan:
docs/superpowers/plans/2026-08-04-deploy-lifecycle-alerts.md🤖 Generated with Claude Code