The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
feat(ci): notify Slack before deployment approval batches (#2954)
kekxyc62f75770e5f
diff --git a/.github/workflows/README.md b/.github/workflows/README.mdindex a553976c2..140111be9 100644--- a/.github/workflows/README.md+++ b/.github/workflows/README.md@@ -80,8 +80,11 @@ Longer treatments live with their subject rather than here: [E2E localrunbook](../../docs/contributing/development/e2e-local.md), [deployment](../../apps/infra/docs/deployment.md).The [release runbook](../../apps/infra/docs/release.md) documents fixed child inputs, timeouts, and recovery.-Full releases require repository secret `SLACK_WEBHOOK_URL` and required reviewers on the `prod` Environment.-The Slack button opens the exact pending prod run; a reviewer approves it with their own GitHub identity.++Full releases require reviewers on the `prod` Environment. A full release can send #release a dev approval link before polling, then the E2E result and prod approval link.++Deployment applies can also notify #dev_deployment for dev or #release for prod before each approval batch. Each button opens the corresponding GitHub run.+Release deployments need one target Environment approval; commit deployments use two batches: parallel artifact preparation, then deploy.Wait until both preparation legs are awaiting review before approving their shared Environment; queued or later jobs can require another review.@@ -458,4 +461,5 @@ Repository secrets, in Settings → Secrets and variables → Actions:- `PYPI_API_TOKEN` — PyPI, for the wheels- `NPM_TOKEN` — npm, for the Node packages- `GH_APP_PRIVATE_KEY` — GitHub App key that registers the self-hosted E2E runner-- `SLACK_WEBHOOK_URL` — incoming webhook for full release reports and the prod approval link+- `SLACK_WEBHOOK_URL` — optional #release webhook for release dev approvals, final reports and prod apply approvals+- `SLACK_DEV_DEPLOYMENT_WEBHOOK_URL` — optional #dev_deployment webhook for dev apply approvals. An empty secret skips that channel.diff --git a/.github/workflows/mbuild-release.yml b/.github/workflows/mbuild-release.ymlindex 9f855d042..f0ee97058 100644--- a/.github/workflows/mbuild-release.yml+++ b/.github/workflows/mbuild-release.yml@@ -203,7 +203,7 @@ jobs:- uses: actions/setup-node@v4with:node-version: '22'- - name: Require notification configuration and release assets+ - name: Validate optional release webhook and require release assetsenv:TAG: ${{ inputs.tag }}SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}@@ -222,6 +222,7 @@ jobs:group: mbuild-release-dev-validationcancel-in-progress: falseoutputs:+ phase: ${{ steps.pipeline.outputs.phase }}dev_run_id: ${{ steps.pipeline.outputs.dev_run_id }}dev_result: ${{ steps.pipeline.outputs.dev_result }}e2e_run_id: ${{ steps.pipeline.outputs.e2e_run_id }}@@ -239,10 +240,14 @@ jobs:env:TAG: ${{ inputs.tag }}RELEASE_SHA: ${{ needs.resolve.outputs.sha }}+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}run: node apps/infra/scripts/release-pipeline.mjs runreport:name: Report release results+ permissions:+ contents: read+ actions: readneeds: [resolve, publish, assets, pipeline]if: ${{ always() && !inputs['build-only'] && github.ref == 'refs/heads/main' }}runs-on: ubuntu-latestdiff --git a/.github/workflows/mdeploy-all.yml b/.github/workflows/mdeploy-all.ymlindex 9b1f0eb0b..82e6f9e6b 100644--- a/.github/workflows/mdeploy-all.yml+++ b/.github/workflows/mdeploy-all.yml@@ -97,10 +97,11 @@ jobs:# it, so `contents: read` is restated. `pull-requests: read` is what lets a# request's merge resolve below, and it is granted here rather than at# workflow level so the jobs that reach a cloud role never carry it — this- # is the only job that reads the API, and it binds no Environment.- # `id-token` is not restated: nothing here federates.+ # is the only job that reads pull requests, and it binds no Environment.+ # The approval notice reads this run's display title through the Actions API.permissions:contents: read+ actions: readpull-requests: readruns-on: ubuntu-latestoutputs:@@ -171,10 +172,12 @@ jobs:[ -z "$version" ] || line="release $version"[ -z "$pr" ] || line="pull request #$pr"- printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"- printf 'pr=%s\n' "$pr" >> "$GITHUB_OUTPUT"- printf 'candidate=%s\n' "$candidate" >> "$GITHUB_OUTPUT"- printf 'line=%s\n' "$line" >> "$GITHUB_OUTPUT"+ {+ printf 'version=%s\n' "$version"+ printf 'pr=%s\n' "$pr"+ printf 'candidate=%s\n' "$candidate"+ printf 'line=%s\n' "$line"+ } >> "$GITHUB_OUTPUT"echo "${STAGE}: ${line}"# A pull request becomes the commit it would merge to, not its head.@@ -348,6 +351,24 @@ jobs:esacfi+ - name: Notify dev reviewers+ if: inputs.apply && inputs.stage == 'dev'+ continue-on-error: true+ env:+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_DEPLOYMENT_WEBHOOK_URL }}+ DEPLOY_ENVIRONMENT: ${{ inputs.stage }}+ APPROVAL_PHASE: ${{ steps.classify.outputs.version != '' && 'Release deployment approval' || 'Commit preparation approval' }}+ run: node apps/infra/scripts/release-pipeline.mjs approval++ - name: Notify prod reviewers+ if: inputs.apply && inputs.stage == 'prod'+ continue-on-error: true+ env:+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}+ DEPLOY_ENVIRONMENT: ${{ inputs.stage }}+ APPROVAL_PHASE: Release deployment approval+ run: node apps/infra/scripts/release-pipeline.mjs approval+# Each commit artifact plans/builds on its own runner; releases use one apply leg.plan:name: ${{ matrix.component == 'release' && 'deploy release' || format('plan and build {0}', matrix.component) }} ${{ inputs.stage }}@@ -537,15 +558,35 @@ jobs:apply: ${{ inputs.apply }}confirm: ${{ inputs.confirm }}+ notify-deploy:+ name: Notify reviewers of the commit deployment+ continue-on-error: true+ needs: [resolve, plan]+ if: inputs.apply && inputs.stage == 'dev' && needs.resolve.outputs.version == '' && needs.plan.result == 'success'+ permissions:+ contents: read+ actions: read+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v5+ with:+ persist-credentials: false+ - name: Notify reviewers+ env:+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_DEPLOYMENT_WEBHOOK_URL }}+ DEPLOY_ENVIRONMENT: ${{ inputs.stage }}+ APPROVAL_PHASE: Commit deployment approval+ run: node apps/infra/scripts/release-pipeline.mjs approval+deploy:name: ${{ inputs.apply && 'deploy' || 'preview' }} ${{ inputs.stage }}permissions:contents: readid-token: writepackages: read- needs: [resolve, plan]+ needs: [resolve, plan, notify-deploy]if: >-- ${{ !cancelled() && !failure() && needs.plan.result == 'success' && needs.resolve.outputs.version == ''+ ${{ !cancelled() && needs.resolve.result == 'success' && needs.plan.result == 'success' && needs.resolve.outputs.version == ''&& (github.ref == 'refs/heads/main' || inputs.stage == 'dev' || inputs.stage == 'stage') }}environment: ${{ inputs.stage }}runs-on: ubuntu-latestdiff --git a/apps/infra/docs/release.md b/apps/infra/docs/release.mdindex eb3ed0e06..35e0583af 100644--- a/apps/infra/docs/release.md+++ b/apps/infra/docs/release.md@@ -1,6 +1,6 @@## TL;DR-Publish a stable release to build its artifacts, validate dev, and receive a Slack link to approve that version's prod deployment.+Publish a stable release to build its artifacts, validate dev and request prod approval in GitHub. Optional Slack messages link reviewers to each deployment.## Release runbook@@ -10,7 +10,6 @@ Pre-release suffixes are unsupported.### Before you start- Merge the version bump into `main` and pass its required checks.-- Configure repository Actions secret `SLACK_WEBHOOK_URL` with a Slack incoming webhook.- Configure required reviewers on the `prod` GitHub Environment.- Ensure the dev/prod stage declarations, cloud credentials, and cloud E2E credentials are configured.- Have permission to start workflows and approve the deployment Environments.@@ -46,11 +45,11 @@ Open **Actions → mbuild-release**:```textPublish all declared images to GHCR→ Wait for required GitHub Release assets- → dispatch mdeploy-all: dev, this tag → wait for success+ → dispatch mdeploy-all: dev, this tag → notify #release → wait for that dev run→ dispatch e2e-cloud: dev, this tag → wait for success→ verify dev deployment history and prod reviewers→ dispatch mdeploy-all: prod, this tag (approval pending)- → report results to Slack and the GitHub job summary+ → write the GitHub job summary and optionally send the release report to #release```The publisher reads the tagged commit's artifact declaration and builds its current four images:@@ -83,7 +82,26 @@ All child workflows run from `main`, with these fixed inputs:The pipeline waits for the exact run IDs returned by GitHub dispatch.A failed, cancelled, or timed-out dev/E2E run prevents the prod request.-Slack reports each stage and links to its specific runs; failed pipelines have no prod approval button.+The GitHub summary includes the E2E result and the prod run link after success, or the failed or interrupted phase.++### Slack approval notices++Configure each incoming webhook as a repository Actions secret for its channel. Each deployment notification step references only its destination’s secret by name.++| Sender | When | Channel and secret |+| --- | --- | --- |+| `mbuild-release` | After dev dispatch and before polling, then again with the final E2E result and prod link on success | #release · `SLACK_WEBHOOK_URL` |+| `mdeploy-all` dev apply | Before the release deployment or commit preparation, and again after successful commit preparation | #dev_deployment · `SLACK_DEV_DEPLOYMENT_WEBHOOK_URL` |+| `mdeploy-all` prod apply | Before the release deployment | #release · `SLACK_WEBHOOK_URL` |++Each notice shows the sending workflow, its run title, GitHub actor, environment and phase. Buttons open GitHub, where reviewers approve the Environment.++For a release-driven dev deployment, both channels receive a link to the same dev child run. A commit with parallel preparation jobs gets one notice for that batch.+Previews, stage deployments and build-only releases skip these notices.++An empty or unset secret skips delivery to its channel. Review a run directly in GitHub if its notice fails.++A supplied malformed release webhook fails the asset preflight. A final delivery failure leaves the GitHub summary available.### 3. Approve the prod request@@ -153,7 +171,7 @@ Rerunning the whole pipeline can create another deployment request.| --- | --- || Missing GitHub Release | Publish the Release matching the tag || Missing required assets | Inspect the runtime/C/Node/wheels/Runner builds; the Runner build follows the C SDK build |-| Invalid or missing webhook | Configure repository secret `SLACK_WEBHOOK_URL`; full mode refuses deployment without it |+| Invalid release webhook | Correct or clear `SLACK_WEBHOOK_URL` before rerunning asset preflight || Missing GHCR image | Recover with `build-only=true`, then inspect downstream runs before restarting || Invalid tag or tag moved | Use an immutable stable release tag whose commit is on `main` || Overlapping dev apply | Finish deployment activity and repeat dev acceptance for the intended release |diff --git a/apps/infra/mdeploy/test/approval-workflow.test.ts b/apps/infra/mdeploy/test/approval-workflow.test.tsindex 0f43ee86e..d2688beed 100644--- a/apps/infra/mdeploy/test/approval-workflow.test.ts+++ b/apps/infra/mdeploy/test/approval-workflow.test.ts@@ -43,6 +43,60 @@ test('published releases require one target Environment approval for verificatiofor (const stage of ['dev', 'prod']) assert.deepEqual(approvedJobs(stage, 'v0.13.1'), ['plan'])})+test('apply notices precede each protected batch and never fall back to another stage secret', () => {+ const { resolve, plan, deploy, 'notify-deploy': second } = workflow.jobs+ const notices = resolve.steps.filter((step: any) => step.run?.endsWith('release-pipeline.mjs approval'))+ const devSecret = '${{ secrets.SLACK_DEV_DEPLOYMENT_WEBHOOK_URL }}'+ const prodSecret = '${{ secrets.SLACK_WEBHOOK_URL }}'+ assert.deepEqual(notices.map((step: any) => step.env.SLACK_WEBHOOK_URL), [devSecret, prodSecret])+ assert.deepEqual(resolve.steps.slice(-2), notices)+ for (const step of notices) assert.equal(step['continue-on-error'], true)+ assert.deepEqual(plan.needs, ['resolve'])+ assert.deepEqual(second.needs, ['resolve', 'plan'])+ assert.ok(deploy.needs.includes('notify-deploy'))+ assert.equal(second.environment, undefined)+ assert.equal(second.strategy, undefined)+ assert.equal(resolve.permissions.actions, 'read')+ assert.deepEqual(second.permissions, { contents: 'read', actions: 'read' })+ const send = second.steps.at(-1)+ for (const step of notices) assert.equal(send.run, step.run)+ assert.equal(send.env.SLACK_WEBHOOK_URL, devSecret)+ assert.equal(send.env.APPROVAL_PHASE, 'Commit deployment approval')+ const expr = (value: string) => value.replace(/^\$\{\{\s*|\s*\}\}$/g, '')+ const batch = new Function('steps', 'return ' + expr(notices[0].env.APPROVAL_PHASE))+ assert.equal(notices[1].env.APPROVAL_PHASE, 'Release deployment approval')+ const next = new Function('inputs', 'needs', 'return ' + second.if)+ for (const stage of ['dev', 'prod', 'stage']) {+ for (const apply of [false, true]) {+ const selected = notices.filter((step: any) => new Function('inputs', 'return ' + step.if)({ stage, apply }))+ const expected = apply && stage !== 'stage' ? [stage === 'dev' ? devSecret : prodSecret] : []+ assert.deepEqual(selected.map((step: any) => step.env.SLACK_WEBHOOK_URL), expected)+ for (const version of ['', 'v1.2.3']) {+ const needs = { resolve: { outputs: { version } }, plan: { result: 'success' } }+ assert.equal(next({ stage, apply }, needs), stage === 'dev' && apply && !version)+ }+ }+ }+ for (const version of ['', 'v1.2.3']) {+ const phase = batch({ classify: { outputs: { version } } })+ assert.equal(phase, version ? 'Release deployment approval' : 'Commit preparation approval')+ }+ for (const result of ['failure', 'cancelled', 'skipped']) {+ const needs = { resolve: { outputs: { version: '' } }, plan: { result } }+ assert.equal(next({ stage: 'dev', apply: true }, needs), false)+ }+ assert.equal(second['continue-on-error'], true)+ const applyJob = new Function('inputs', 'github', 'needs', 'cancelled', 'return (' + expr(deploy.if) + ')')+ for (const result of ['failure', 'skipped', 'success']) {+ const needs = {+ resolve: { result: 'success', outputs: { version: '' } },+ plan: { result: 'success' },+ 'notify-deploy': { result },+ }+ assert.equal(applyJob({ stage: 'dev' }, { ref: 'refs/heads/main' }, needs, () => false), true)+ }+})+test('shared operations declare every input they read and preserve the original requested ref', () => {for (const name of ['mbuild', 'mdeploy', 'build-staged-runner']) {const source = actionSource(name)@@ -82,7 +136,7 @@ test('failure and cancellation prevent the separate commit apply job', () => {assert.equal(evaluate({ stage: 'dev' },{ ref: 'refs/heads/main' },- { resolve: { outputs: { version: '' } }, plan: { result } },+ { resolve: { result: 'success', outputs: { version: '' } }, plan: { result } },() => result === 'cancelled',() => result === 'failure',), result === 'success', `preparation ${result}`)diff --git a/apps/infra/mdeploy/test/orchestrator.test.ts b/apps/infra/mdeploy/test/orchestrator.test.tsindex bfb16cb00..8d06f8cf0 100644--- a/apps/infra/mdeploy/test/orchestrator.test.ts+++ b/apps/infra/mdeploy/test/orchestrator.test.ts@@ -265,5 +265,5 @@ test('a stage that already holds everything still deploys', () => {for (const job of ACTING.filter((name) => name !== 'deploy')) {assert.match(deploy, new RegExp(`needs: \\[[^\\]]*${job}[^\\]]*\\]`), `the deploy does not wait for ${job}`)}- assert.match(deploy, /!cancelled\(\) && !failure\(\)/, 'a skipped artifact job would skip the deploy')+ assert.match(deploy, /!cancelled\(\)/, 'deployment must check cancellation even when a notice is skipped')})diff --git a/apps/infra/mdeploy/test/parallel-build.test.ts b/apps/infra/mdeploy/test/parallel-build.test.tsindex 5607731b8..455dad61d 100644--- a/apps/infra/mdeploy/test/parallel-build.test.ts+++ b/apps/infra/mdeploy/test/parallel-build.test.ts@@ -82,5 +82,5 @@ esacassert.equal(workflow.jobs.resolve.outputs.prepare_components, '${{ steps.tag.outputs.prepare_components }}')assert.equal(plan.outputs, undefined, 'matrix outputs must not choose the commit deployment route')assert.equal(workflow.jobs.deploy.steps.find((step: any) => step.uses === './.github/actions/mdeploy').with['api-route'], 'skip')- assert.deepEqual(workflow.jobs.deploy.needs, ['resolve', 'plan'])+ assert.deepEqual(workflow.jobs.deploy.needs, ['resolve', 'plan', 'notify-deploy'])})diff --git a/apps/infra/scripts/release-pipeline.mjs b/apps/infra/scripts/release-pipeline.mjsindex 4dd1fbeea..51a5187de 100644--- a/apps/infra/scripts/release-pipeline.mjs+++ b/apps/infra/scripts/release-pipeline.mjs@@ -68,13 +68,55 @@ export const slackWebhook = (value) => {return url.href}+async function githubRequest(repo, token, request, path, body) {+ const method = body === undefined ? 'GET' : 'POST'+ let response+ try {+ response = await request('https://api.github.com/repos/' + repo + path, {+ method,+ headers: {+ Authorization: 'Bearer ' + token,+ Accept: 'application/vnd.github+json',+ 'Content-Type': 'application/json',+ 'X-GitHub-Api-Version': '2026-03-10',+ },+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),+ redirect: 'error',+ signal: AbortSignal.timeout(30_000),+ })+ } catch {+ throw new Error(+ method === 'POST' ? 'Dispatch outcome unknown; inspect GitHub before retrying' : 'GitHub read failed',+ )+ }+ if (!response.ok) {+ throw new Error(+ 'GitHub ' ++ method ++ ' failed: HTTP ' ++ response.status ++ (method === 'POST' && response.status >= 500 ? '; dispatch outcome unknown, inspect before retrying' : ''),+ )+ }+ try {+ const result = await response.json()+ if (result === null || typeof result !== 'object') throw new Error('Invalid JSON document')+ return result+ } catch {+ throw new Error(+ method === 'POST'+ ? 'Dispatch outcome unknown: no readable run ID; inspect before retrying'+ : 'Malformed GitHub JSON response',+ )+ }+}+export class ReleasePipeline {#repo#requiredAssets#tag#sha- #token- #request+ #api#timer#record#log@@ -85,56 +127,12 @@ export class ReleasePipeline {if (!token) throw new Error('GH_TOKEN is required')this.#tag = tagthis.#sha = sha- this.#token = token- this.#request = request+ this.#api = (path, body) => githubRequest(this.#repo, token, request, path, body)this.#timer = timerthis.#record = recordthis.#log = log}- async #api(path, body) {- const method = body === undefined ? 'GET' : 'POST'- let response- try {- response = await this.#request('https://api.github.com/repos/' + this.#repo + path, {- method,- headers: {- Authorization: 'Bearer ' + this.#token,- Accept: 'application/vnd.github+json',- 'Content-Type': 'application/json',- 'X-GitHub-Api-Version': '2026-03-10',- },- ...(body === undefined ? {} : { body: JSON.stringify(body) }),- redirect: 'error',- signal: AbortSignal.timeout(30_000),- })- } catch {- throw new Error(- method === 'POST' ? 'Dispatch outcome unknown; inspect GitHub before retrying' : 'GitHub read failed',- )- }- if (!response.ok) {- throw new Error(- 'GitHub ' +- method +- ' failed: HTTP ' +- response.status +- (method === 'POST' && response.status >= 500 ? '; dispatch outcome unknown, inspect before retrying' : ''),- )- }- try {- const result = await response.json()- if (result === null || typeof result !== 'object') throw new Error('Invalid JSON document')- return result- } catch {- throw new Error(- method === 'POST'- ? 'Dispatch outcome unknown: no readable run ID; inspect before retrying'- : 'Malformed GitHub JSON response',- )- }- }-async #poll(read, timeout, describe) {const deadline = this.#timer.now() + timeoutwhile (this.#timer.now() < deadline) {@@ -255,13 +253,28 @@ export class ReleasePipeline {throw new Error('Deployment history was truncated; refusing a prod request')}- async run() {+ async run(notifyDev) {const inputs = { stage: 'dev', components: 'api+runner', ref: this.#tag, apply: true, confirm: true }+ this.#record('phase', 'dev_dispatch')const devId = await this.#dispatch('mdeploy-all.yml', inputs, 'dev')+ this.#record('phase', 'dev_wait')+ if (notifyDev) {+ try {+ await notifyDev(devId)+ } catch {+ this.#log(+ '::warning::Dev approval notice failed. Follow https://github.com/' + this.#repo + '/actions/runs/' + devId,+ )+ }+ }const dev = await this.#completed(devId, 'dev', 3 * HOUR)+ this.#record('phase', 'e2e_dispatch')const e2eId = await this.#dispatch('e2e-cloud.yml', { stage: 'dev', tag: this.#tag }, 'e2e')+ this.#record('phase', 'e2e_wait')const e2e = await this.#completed(e2eId, 'e2e', HOUR)+ this.#record('phase', 'history')await this.#undisturbed(dev, e2e)+ this.#record('phase', 'prod_reviewers')const environment = await this.#api('/environments/prod')if (!Array.isArray(environment.protection_rules) ||@@ -272,10 +285,46 @@ export class ReleasePipeline {throw new Error('Prod must have required Environment reviewers before a prod run can be created')}// Creation fixes inputs; GitHub Environment approval remains a separate human action.+ this.#record('phase', 'prod_dispatch')await this.#dispatch('mdeploy-all.yml', { ...inputs, stage: 'prod' }, 'prod')}}+const reviewButton = (repo, runId, environment) => ({+ type: 'actions',+ elements: [+ {+ type: 'button',+ style: 'primary',+ text: { type: 'plain_text', text: 'Review ' + environment + ' deployment' },+ url: 'https://github.com/' + repository(repo) + '/actions/runs/' + id(Number(runId)),+ },+ ],+})++const releasePhases = {+ dev_dispatch: ['dev', 'Dev deployment dispatch'],+ dev_wait: ['dev', 'Dev deployment'],+ e2e_dispatch: ['dev', 'E2E dispatch'],+ e2e_wait: ['dev', 'E2E cloud'],+ history: ['dev', 'Dev validation history'],+ prod_reviewers: ['prod', 'Prod reviewer verification'],+ prod_dispatch: ['prod', 'Prod deployment dispatch'],+}++const stoppedPhase = (results) => {+ for (const [job, label] of [+ ['resolve', 'Release ref resolution'],+ ['publish', 'Image publication'],+ ['assets', 'Release assets'],+ ]) {+ if (results[job]?.result && results[job].result !== 'success') return ['Pre-deployment', label]+ }+ return (+ releasePhases[results.pipeline?.outputs?.phase] ?? ['Release', 'Release orchestration (last phase unavailable)']+ )+}+export const releaseReport = ({ repo, tag, runId, results }) => {repository(repo)const source = 'https://github.com/' + repo@@ -285,7 +334,12 @@ export const releaseReport = ({ repo, tag, runId, results }) => {/^[1-9][0-9]*$/.test(String(value ?? '')) ? '<' + source + '/actions/runs/' + value + '|' + label + '>' : labelconst success = pipeline.result === 'success' && /^[1-9][0-9]*$/.test(outputs.prod_run_id ?? '')const release = VERSION.test(tag) ? tag : '(invalid release tag)'- const title = release + (success ? ': dev verified; prod review requested' : ': release pipeline failed')+ const [environment, phase] = success ? ['prod', 'Prod deployment approval'] : stoppedPhase(results)+ const interrupted = Object.values(results).some((job) => job.result === 'cancelled')+ const outcome = interrupted ? 'interrupted' : 'failed'+ const title = success+ ? release + ': dev verified; prod review requested'+ : release + ': release pipeline ' + outcome + ' at ' + phaseconst rows = [['Publication', results.publish?.result ?? 'not started'],['Release assets', results.assets?.result ?? 'not started'],@@ -309,17 +363,7 @@ export const releaseReport = ({ repo, tag, runId, results }) => {', components=api+runner, apply=true, confirm=true. Review and approve in GitHub.',},})- blocks.push({- type: 'actions',- elements: [- {- type: 'button',- style: 'primary',- text: { type: 'plain_text', text: 'Review prod deployment' },- url: source + '/actions/runs/' + outputs.prod_run_id,- },- ],- })+ blocks.push(reviewButton(repo, outputs.prod_run_id, 'prod'))}const summary ='## ' +@@ -330,7 +374,7 @@ export const releaseReport = ({ repo, tag, runId, results }) => {.join('\n') +'\n' +(success ? '\nProd run: ' + source + '/actions/runs/' + outputs.prod_run_id + '\n' : '')- return { payload: { text: title, blocks }, summary }+ return { payload: { text: title, blocks }, summary, environment, phase }}export const sendSlack = async (webhook, payload, request = fetch) => {@@ -350,6 +394,47 @@ export const sendSlack = async (webhook, payload, request = fetch) => {if (!response.ok) throw new Error('Slack notification failed: HTTP ' + response.status)}+async function sendRunSlack({ payload, environment, phase }) {+ const {+ SLACK_WEBHOOK_URL: webhook,+ GITHUB_REPOSITORY,+ GITHUB_RUN_ID,+ GITHUB_WORKFLOW,+ GITHUB_ACTOR,+ GH_TOKEN,+ } = process.env+ if (!webhook) return+ slackWebhook(webhook)+ const runId = id(Number(GITHUB_RUN_ID))+ const run = await githubRequest(repository(GITHUB_REPOSITORY), GH_TOKEN, fetch, '/actions/runs/' + runId)+ if (run.id !== runId || !run.display_title || typeof run.display_title !== 'string') {+ throw new Error('GitHub returned no title for the sending workflow run')+ }+ const fields = [+ ['Workflow', GITHUB_WORKFLOW],+ ['Run', run.display_title],+ ['GitHub actor', GITHUB_ACTOR],+ ['Environment', environment],+ ['Phase', phase],+ ].map(([label, value]) => ({ type: 'plain_text', text: label + '\n' + value }))+ const [header, ...details] = payload.blocks+ await sendSlack(webhook, { ...payload, blocks: [header, { type: 'section', fields }, ...details] })+}++function notifyApproval(runId, environment, phase, title) {+ return sendRunSlack({+ environment,+ phase,+ payload: {+ text: title,+ blocks: [+ { type: 'header', text: { type: 'plain_text', text: title } },+ reviewButton(process.env.GITHUB_REPOSITORY, runId, environment),+ ],+ },+ })+}+if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) {try {if (process.argv[2] === 'report') {@@ -360,7 +445,14 @@ if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1results: JSON.parse(process.env.RELEASE_RESULTS),})if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, report.summary)- await sendSlack(process.env.SLACK_WEBHOOK_URL, report.payload)+ await sendRunSlack(report)+ } else if (process.argv[2] === 'approval') {+ const { DEPLOY_ENVIRONMENT, APPROVAL_PHASE, GITHUB_RUN_ID } = process.env+ try {+ await notifyApproval(GITHUB_RUN_ID, DEPLOY_ENVIRONMENT, APPROVAL_PHASE, 'Deployment review requested')+ } catch {+ console.warn('::warning::Deployment approval notice failed. Review this run in GitHub.')+ }} else {const pipeline = new ReleasePipeline({repo: process.env.GITHUB_REPOSITORY,@@ -369,10 +461,13 @@ if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1token: process.env.GH_TOKEN,})if (process.argv[2] === 'assets') {- slackWebhook(process.env.SLACK_WEBHOOK_URL)+ if (process.env.SLACK_WEBHOOK_URL) slackWebhook(process.env.SLACK_WEBHOOK_URL)await pipeline.waitForAssets()- } else if (process.argv[2] === 'run') await pipeline.run()- else throw new Error('Expected assets, run, or report')+ } else if (process.argv[2] === 'run') {+ await pipeline.run((devId) =>+ notifyApproval(devId, 'dev', 'Dev deployment approval', process.env.TAG + ': dev deployment dispatched'),+ )+ } else throw new Error('Expected assets, run, report, or approval')}} catch (error) {console.error(error instanceof Error ? error.message : 'Release pipeline failed')diff --git a/apps/infra/scripts/release-pipeline.test.mjs b/apps/infra/scripts/release-pipeline.test.mjsindex b6c63a057..d4c865d8c 100644--- a/apps/infra/scripts/release-pipeline.test.mjs+++ b/apps/infra/scripts/release-pipeline.test.mjs@@ -11,6 +11,7 @@ import { ReleasePipeline, releaseAssets, releaseReport, sendSlack, slackWebhookconst snapshot = JSON.parse(readFileSync(new URL('./fixtures/release-v0.13.1-assets.json', import.meta.url), 'utf8'))const repo = 'boxlite-ai/boxlite'+const displayTitle = 'deploy dev · <@requested_by> · <!channel> & review'const tag = snapshot.tag_nameconst sha = '6c5855a654beb3ba952faceb9665b5c563770859'const webhook = 'https://hooks.slack.com/services/Tfixture/Bfixture/private-fixture-token'@@ -117,7 +118,8 @@ const cliHarness = (t) => {' const address = new URL(url)',' const body = init.body ? JSON.parse(init.body) : undefined'," appendFileSync(process.env.RELEASE_TEST_REQUESTS, JSON.stringify({ url, method: init.method, body }) + '\\n')",- " if (address.hostname === 'hooks.slack.com') return new Response('ok')",+ " if (address.hostname === 'hooks.slack.com') return new Response('ok', { status: Number(process.env.SLACK_TEST_STATUS || 200) })",+ " if (address.pathname.endsWith('/actions/runs/10')) return Response.json({ id: 10, display_title: process.env.TEST_TITLE }, { status: Number(process.env.TITLE_TEST_STATUS || 200) })"," if (address.hostname !== 'api.github.com') throw new Error('Unexpected test host')"," if (init.method === 'POST' && address.pathname.endsWith('/dispatches')) {",' return Response.json({ workflow_run_id: body.inputs.stage === "prod" ? 303 : body.inputs.tag ? 202 : 101 })',@@ -155,6 +157,9 @@ const cliHarness = (t) => {...process.env,GITHUB_REPOSITORY: repo,GITHUB_RUN_ID: '10',+ GITHUB_WORKFLOW: 'mbuild-release',+ GITHUB_ACTOR: 'github-actor',+ TEST_TITLE: displayTitle,GITHUB_OUTPUT: output,GITHUB_STEP_SUMMARY: summary,TAG: tag,@@ -196,28 +201,49 @@ test('workflow CLI waits for assets, records child runs, and reports their prode2e_run_id: '202',e2e_result: 'success',prod_run_id: '303',+ phase: 'prod_dispatch',})- const dispatches = pipeline.requests.filter((request) => request.method === 'POST')+ const dispatches = pipeline.requests.filter((request) => request.url.endsWith('/dispatches'))assert.equal(dispatches.length, 3)for (const request of dispatches) assert.equal(request.body.inputs.ref ?? request.body.inputs.tag, tag)+ const notices = pipeline.requests.filter((request) => request.url === webhook)+ assert.equal(notices.length, 1)+ const dev = notices[0]+ assert.ok(pipeline.requests.indexOf(dev) > pipeline.requests.indexOf(dispatches[0]))+ assert.ok(pipeline.requests.indexOf(dev) < pipeline.requests.findIndex((r) => r.url.endsWith('/actions/runs/101')))+ assert.equal(dev.body.blocks.at(-1).elements[0].url, 'https://github.com/' + repo + '/actions/runs/101')const report = cli('report', {RELEASE_RESULTS: JSON.stringify({ pipeline: { result: 'success', outputs } }),})assert.equal(report.status, 0, report.stderr)assert.match(report.summary, /Prod run: https:\/\/github.com\/boxlite-ai\/boxlite\/actions\/runs\/303/)- assert.equal(report.requests.length, 1)- const actions = report.requests[0].body.blocks.find((block) => block.type === 'actions')+ const final = report.requests.find((r) => r.url === webhook)+ for (const [message, environment] of [+ [dev.body, 'dev'],+ [final.body, 'prod'],+ ]) {+ const fields = message.blocks.flatMap((b) => b.fields ?? []).filter((f) => f.type === 'plain_text')+ for (const value of [displayTitle, 'mbuild-release', 'github-actor', environment]) {+ assert.ok(+ fields.some((f) => f.text.endsWith('\n' + value)),+ value,+ )+ }+ assert.ok(fields.some((f) => f.text.startsWith('Phase\n') && f.text.length > 6))+ assert.ok(!JSON.stringify(message.blocks.filter((b) => !b.fields)).includes('<!channel>'))+ }+ const actions = final.body.blocks.find((block) => block.type === 'actions')assert.equal(actions.elements[0].url, 'https://github.com/' + repo + '/actions/runs/' + outputs.prod_run_id)})test('workflow CLI rejects invalid configuration without network calls and preserves a failed report summary', (t) => {const cli = cliHarness(t)for (const [command, overrides, error] of [- ['assets', { SLACK_WEBHOOK_URL: '' }, /SLACK_WEBHOOK_URL/],- ['unknown', {}, /Expected assets, run, or report/],+ ['assets', { SLACK_WEBHOOK_URL: 'malformed' }, /SLACK_WEBHOOK_URL/],+ ['unknown', {}, /Expected assets, run, report, or approval/],['run', { TAG: 'main' }, /TAG must be/],['run', { GH_TOKEN: '' }, /GH_TOKEN is required/],- ['report', { SLACK_WEBHOOK_URL: '' }, /SLACK_WEBHOOK_URL/],+ ['report', { SLACK_WEBHOOK_URL: 'malformed' }, /SLACK_WEBHOOK_URL/],]) {const result = cli(command, overrides)assert.equal(result.status, 1, result.stderr)@@ -227,6 +253,72 @@ test('workflow CLI rejects invalid configuration without network calls and prese}})+test('missing release webhook preserves asset checks, all dispatches and the final summary', (t) => {+ const cli = cliHarness(t)+ for (const secret of [undefined, '']) {+ for (const command of ['assets', 'run', 'report']) {+ const result = cli(command, { SLACK_WEBHOOK_URL: secret })+ assert.equal(result.status, 0, result.stderr)+ assert.ok(result.requests.every((r) => r.url.startsWith('https://api.github.com/')))+ if (command === 'assets') assert.ok(result.requests.some((r) => r.url.includes('/assets?')))+ if (command === 'run') assert.match(result.output, /prod_run_id=303/)+ if (command === 'report') assert.match(result.summary, /Release assets/)+ }+ }+})++test('a failed notice or title lookup still follows the dispatched child exactly once', (t) => {+ const cli = cliHarness(t)+ for (const overrides of [{ SLACK_TEST_STATUS: '503' }, { TITLE_TEST_STATUS: '403' }]) {+ const result = cli('run', overrides)+ assert.equal(result.status, 0, result.stderr)+ assert.match(result.stdout + result.stderr, /::warning::.*101/)+ assert.doesNotMatch(result.stdout + result.stderr, /private-fixture-token/)+ assert.equal(result.requests.filter((r) => r.url === webhook).length, overrides.SLACK_TEST_STATUS ? 1 : 0)+ assert.equal(+ result.requests.filter((r) => r.url.endsWith('/mdeploy-all.yml/dispatches') && r.body.inputs.stage === 'dev')+ .length,+ 1,+ )+ assert.match(result.output, /prod_run_id=303/)+ }+})++test('deployment CLI identifies the sender, approval batch and current run', (t) => {+ const cli = cliHarness(t)+ const env = {+ GITHUB_WORKFLOW: 'mdeploy-all',+ DEPLOY_ENVIRONMENT: 'dev',+ APPROVAL_PHASE: 'Commit preparation approval',+ }+ const result = cli('approval', env)+ assert.equal(result.status, 0, result.stderr)+ const message = result.requests.find((r) => r.url === webhook).body+ assert.equal(message.blocks.at(-1).elements[0].url, 'https://github.com/' + repo + '/actions/runs/10')+ const fields = message.blocks.flatMap((b) => b.fields ?? [])+ for (const value of [env.GITHUB_WORKFLOW, env.DEPLOY_ENVIRONMENT, env.APPROVAL_PHASE, 'github-actor', displayTitle]) {+ assert.ok(fields.some((f) => f.type === 'plain_text' && f.text.endsWith('\n' + value)))+ }+ const disabled = cli('approval', { ...env, SLACK_WEBHOOK_URL: '' })+ assert.equal(disabled.status, 0, disabled.stderr)+ assert.deepEqual(disabled.requests, [])+})++test('failed and cancelled reports name the interrupted phase without prompting for approval', () => {+ for (const [results, phase] of [+ [{ resolve: { result: 'failure' } }, 'Release ref resolution'],+ [{ publish: { result: 'failure' }, assets: { result: 'skipped' } }, 'Image publication'],+ [{ assets: { result: 'cancelled' } }, 'Release assets'],+ [{ pipeline: { result: 'failure', outputs: { phase: 'history' } } }, 'Dev validation history'],+ [{ pipeline: { result: 'cancelled', outputs: { phase: 'e2e_wait' } } }, 'E2E cloud'],+ [{ pipeline: { result: 'failure', outputs: { phase: 'prod_reviewers' } } }, 'Prod reviewer verification'],+ ]) {+ const { payload, summary } = releaseReport({ repo, tag, runId: '10', results })+ assert.ok(payload.text.includes(phase) && summary.includes(phase))+ assert.ok(!payload.blocks.some((b) => b.type === 'actions'))+ }+})+test('required assets agree with the real Release snapshot and production consumers', () => {const required = releaseAssets(tag)assert.ok(@@ -313,6 +405,7 @@ test('full pipeline dispatches exact child IDs and preserves the release acrosse2e_run_id: '202',e2e_result: 'success',prod_run_id: '303',+ phase: 'prod_dispatch',})assert.equal(h.waits.length, 1)assert.ok(!h.calls.some((call) => call.path.endsWith('/actions/runs/303')))@@ -332,6 +425,7 @@ test('failed and cancelled dev runs stop before E2E or prod dispatch', async ()assert.equal(h.calls.filter((call) => call.method === 'POST').length, 1)assert.equal(h.records.dev_run_id, '101')assert.equal(h.records.dev_result, conclusion)+ assert.equal(h.records.phase, 'dev_wait')}})@@ -361,7 +455,14 @@ test('deployment and E2E deadlines stop dispatching without cancelling children'test('uncertain dispatch responses are not retried or replaced with the latest run', async () => {for (const response of [new Response(null, { status: 204 }), json({ workflow_run_id: 0 }), json({}, 503)]) {const h = harness({ respond: (call) => (call.method === 'POST' ? response.clone() : undefined) })- await assert.rejects(h.client.run(), /unknown|valid run ID/)+ let notified = false+ await assert.rejects(+ h.client.run(() => {+ notified = true+ }),+ /unknown|valid run ID/,+ )+ assert.equal(notified, false)assert.equal(h.calls.filter((call) => call.method === 'POST').length, 1)assert.ok(!h.calls.some((call) => call.path.includes('/runs?')))}