FORGE-433: make the deploy's Worker secret sync work and fail loudly #1245

Merged
gmackie merged 1 commit from forge-433-secret-sync into main 2026-11-22 18:35:37 +00:00
Owner

FORGE-433 — https://tasks.gmac.io/gmacko/issue/FORGE-433

Problem

The production deploy's "Sync secrets to CF Worker" step failed on every run (wrangler secret list: exit status 1). Because it was continue-on-error, deploys stayed green and new store secrets never reached the forgegraf Worker.

Root cause

It was the only wrangler step in deploy.yml without CLOUDFLARE_ACCOUNT_ID. The CI API token reaches more than one Cloudflare account, and wrangler cannot choose one non-interactively (deploy-staging.yml already notes this). listCFSecrets used exec.Command(...).Output(), which discarded wrangler's stderr, so the log never said why.

Changes

  • deploy.yml: pass CLOUDFLARE_ACCOUNT_ID to the sync step (and to the rollback step, which had the same gap). Drop continue-on-error. Give the step the id secret_sync, and have "Report deploy failure" record it. A sync failure does not roll back the healthy Worker.
  • forge secret sync:
    • surfaces wrangler's stderr (list and bulk; neither echoes values)
    • refuses a non-interactive API-token run without an account ID
    • parses the JSON list strictly (the old line fallback could invent names)
    • re-lists the Worker after the bulk put and fails if a synced key is missing
    • adds --stage and --name so other Workers can be filled through the same path
    • never syncs production-only keys (the Forgejo token-admin service account) to a non-production stage. Beta keeps its own secret set, and its forgejo-token API answers 503 "not configured". The post-sync check covers only the keys synced for that stage, so each environment's required set is its own.
  • scripts/test-secret-sync-step.mjs (wired into CI) pins the workflow contract; Go unit tests cover the CLI changes. deploy-source-report.test.ts now pins the sync as blocking instead of advisory.

Acceptance criteria

  • The next production deploy log shows a successful sync plan ("Nothing to sync." or N create/update) and the step passes.
  • A newly set store secret reaches the Worker without a manual put.
  • A failed sync makes the deploy fail visibly.

🤖 Generated with Claude Code

FORGE-433 — https://tasks.gmac.io/gmacko/issue/FORGE-433 ## Problem The production deploy's "Sync secrets to CF Worker" step failed on every run (`wrangler secret list: exit status 1`). Because it was `continue-on-error`, deploys stayed green and new store secrets never reached the `forgegraf` Worker. ## Root cause It was the only wrangler step in `deploy.yml` without `CLOUDFLARE_ACCOUNT_ID`. The CI API token reaches more than one Cloudflare account, and wrangler cannot choose one non-interactively (`deploy-staging.yml` already notes this). `listCFSecrets` used `exec.Command(...).Output()`, which discarded wrangler's stderr, so the log never said why. ## Changes - `deploy.yml`: pass `CLOUDFLARE_ACCOUNT_ID` to the sync step (and to the rollback step, which had the same gap). Drop `continue-on-error`. Give the step the id `secret_sync`, and have "Report deploy failure" record it. A sync failure does not roll back the healthy Worker. - `forge secret sync`: - surfaces wrangler's stderr (list and bulk; neither echoes values) - refuses a non-interactive API-token run without an account ID - parses the JSON list strictly (the old line fallback could invent names) - re-lists the Worker after the bulk put and fails if a synced key is missing - adds `--stage` and `--name` so other Workers can be filled through the same path - never syncs production-only keys (the Forgejo token-admin service account) to a non-production stage. Beta keeps its own secret set, and its forgejo-token API answers 503 "not configured". The post-sync check covers only the keys synced for that stage, so each environment's required set is its own. - `scripts/test-secret-sync-step.mjs` (wired into CI) pins the workflow contract; Go unit tests cover the CLI changes. `deploy-source-report.test.ts` now pins the sync as blocking instead of advisory. ## Acceptance criteria - The next production deploy log shows a successful sync plan ("Nothing to sync." or N create/update) and the step passes. - A newly set store secret reaches the Worker without a manual put. - A failed sync makes the deploy fail visibly. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
FORGE-433: make the deploy's Worker secret sync work and fail loudly
Some checks failed
Preview / cleanup (pull_request) Has been skipped
CI / superseded (pull_request) Successful in 3s
CI / gitleaks (pull_request) Successful in 25s
Preview / deploy (pull_request) Has been skipped
CI / storybook (pull_request) Successful in 2m48s
CI / web-build (pull_request) Successful in 4m2s
CI / checks (pull_request) Successful in 2m44s
CI / unit-api (pull_request) Failing after 2m56s
CI / database-d1 (pull_request) Has been skipped
CI / go (pull_request) Successful in 49s
Preview / e2e (pull_request) Has been skipped
Preview / release (pull_request) Has been skipped
CI / database (pull_request) Successful in 3m24s
CI / unit-web (pull_request) Successful in 5m58s
CI / ci (pull_request) Failing after 1m15s
0a9104f13e
The production deploy's "Sync secrets to CF Worker" step failed on every
run (wrangler secret list: exit status 1) while continue-on-error kept the
deploy green, so new store secrets never reached the forgegraf Worker.

Root cause: it was the only wrangler step without CLOUDFLARE_ACCOUNT_ID. The
CI API token reaches more than one Cloudflare account, and wrangler cannot
choose one non-interactively (deploy-staging.yml already notes this).
listCFSecrets discarded wrangler's stderr, so the log never said why.

- deploy.yml: pass CLOUDFLARE_ACCOUNT_ID to the sync (and to rollback), drop
  continue-on-error, and report a sync failure as a failed deploy without
  rolling back the healthy Worker.
- forge secret sync: surface wrangler stderr, refuse a non-interactive API
  token without an account id, parse the JSON list strictly (no line
  fallback inventing names), verify every synced key is listed on the
  Worker afterwards, and add --stage / --name for other Workers.
- scripts/test-secret-sync-step.mjs pins the workflow contract in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gmackie force-pushed forge-433-secret-sync from 0a9104f13e
Some checks failed
Preview / cleanup (pull_request) Has been skipped
CI / superseded (pull_request) Successful in 3s
CI / gitleaks (pull_request) Successful in 25s
Preview / deploy (pull_request) Has been skipped
CI / storybook (pull_request) Successful in 2m48s
CI / web-build (pull_request) Successful in 4m2s
CI / checks (pull_request) Successful in 2m44s
CI / unit-api (pull_request) Failing after 2m56s
CI / database-d1 (pull_request) Has been skipped
CI / go (pull_request) Successful in 49s
Preview / e2e (pull_request) Has been skipped
Preview / release (pull_request) Has been skipped
CI / database (pull_request) Successful in 3m24s
CI / unit-web (pull_request) Successful in 5m58s
CI / ci (pull_request) Failing after 1m15s
to daa7f2f220
Some checks failed
Preview / cleanup (pull_request) Has been skipped
CI / superseded (pull_request) Successful in 11s
CI / gitleaks (pull_request) Successful in 27s
Preview / deploy (pull_request) Has been skipped
CI / storybook (pull_request) Successful in 1m19s
CI / checks (pull_request) Successful in 3m15s
CI / unit-api (pull_request) Successful in 2m38s
CI / database-d1 (pull_request) Has been skipped
CI / web-build (pull_request) Successful in 4m4s
CI / go (pull_request) Successful in 47s
CI / unit-web (pull_request) Successful in 4m13s
CI / database (pull_request) Successful in 2m51s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 42s
Preview / e2e (pull_request) Has been cancelled
Preview / release (pull_request) Has been cancelled
2026-11-22 17:40:44 +00:00
Compare
gmackie force-pushed forge-433-secret-sync from daa7f2f220
Some checks failed
Preview / cleanup (pull_request) Has been skipped
CI / superseded (pull_request) Successful in 11s
CI / gitleaks (pull_request) Successful in 27s
Preview / deploy (pull_request) Has been skipped
CI / storybook (pull_request) Successful in 1m19s
CI / checks (pull_request) Successful in 3m15s
CI / unit-api (pull_request) Successful in 2m38s
CI / database-d1 (pull_request) Has been skipped
CI / web-build (pull_request) Successful in 4m4s
CI / go (pull_request) Successful in 47s
CI / unit-web (pull_request) Successful in 4m13s
CI / database (pull_request) Successful in 2m51s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 42s
Preview / e2e (pull_request) Has been cancelled
Preview / release (pull_request) Has been cancelled
to 7cf9de2d50
All checks were successful
CI / superseded (pull_request) Successful in 1m29s
CI / gitleaks (pull_request) Successful in 27s
CI / storybook (pull_request) Successful in 1m34s
CI / checks (pull_request) Successful in 1m12s
CI / unit-api (pull_request) Successful in 41s
CI / unit-web (pull_request) Successful in 2m6s
CI / database-d1 (pull_request) Has been skipped
CI / web-build (pull_request) Successful in 4m15s
CI / go (pull_request) Successful in 1m13s
CI / database (pull_request) Successful in 3m31s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 2m33s
Preview / cleanup (pull_request) Has been skipped
Preview / deploy (pull_request) Has been skipped
Preview / e2e (pull_request) Has been skipped
Preview / release (pull_request) Has been skipped
2026-11-22 18:03:08 +00:00
Compare
Sign in to join this conversation.
No description provided.