Skip to content

feat(deploy): keep the previous release's web files, and write the deploy down - #167

Merged
aRustyDev merged 3 commits into
mainfrom
feat/deploy-assets-and-docs
Nov 14, 2026
Merged

aRustyDev merged 3 commits into
mainfrom
feat/deploy-assets-and-docs

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

What this does

The last of the four PRs for the deploy pipeline (ADR-0110, issue #49). #153, #154 and #165 are merged.

The deployed Worker now serves the web app, and a deploy keeps the web files of the release before it. ADR-0011 has a missing hashed file answered 200 text/html (the single-page fallback), so a tab opened on release N-1 that asks for one of its scripts after N has gone out gets HTML where it expected JavaScript. Each deploy uploads the new release's files and the previous release's, never more than those two.

  • wrangler.deploy.toml gets [assets]: single-page fallback, and the same run_worker_first list as scripts/worker-dev.sh. The parity test checks the list is the same, and that wrangler.toml has no [assets].
  • The build job builds the web app and puts it in the attested bundle with the Worker.
  • The deploy fetches the previous release's bundle (fetch-previous-assets.sh): unexpired artifacts from a run on main, newest first, then gh attestation verify (verify-bundle.sh) and unpack-bundle.sh, which refuses links, special files, absolute and .. paths and a BUILD_SHA that is another commit's. A pull request from a fork can upload an artifact under any name, so the name is not trusted. merge-assets.sh then merges the two sets of files. A previous release it cannot read is a failure; the first deploy, which has none, is the one case that goes without.
  • After the smoke, check-asset-retention.sh asks the deployed Worker for scripts only the previous release had, and requires 200, a JavaScript content type and the previous release's bytes. A failure rolls back as a failed smoke does. The checker is shown to flag a text/html answer (issue AC 5).
  • GH_TOKEN is withheld from wrangler, the smoke and the expand step, the way the Cloudflare secrets are from the fetch. Each fake in the test reports which secrets it could see.
  • Docs: docs/src/architecture/deploy.md is the runbook (environments, first deploy, ordinary and DO-lifecycle deploys, the rollback drill, rolling back by hand, rotating the token). cicd.md and infra.md no longer say there is no CD. ADR-0110 and ADR-0101 and QUESTIONS.md record the round-30 answers, including that GitHub OIDC was not achieved: a scoped API token in each environment's secrets stands in, by the owner's decision of 2026-11-13. G-36 in docs/src/testing/status.md records what is covered only against stand-ins.

Refs, not Fixes

This PR refers to the issue in a Refs: footer and leaves it open. The issue's acceptance criteria 2, 4 and 5 are runtime controls on staging; they are shown so far only against a stand-in Cloudflare. Merging this finishes the build, not the issue. Say so if you want a closing keyword added before you merge, or close the issue by hand after the staging drill passes.

Verified

Under dash, all green: check-deps, check-topology (and --self-test), check-placement, check-plane-500 and check-acceptance-list (and their self-tests), render-wrangler --self-test, lint-workflow on deploy.yml and the action, every .github/scripts/tests/test-*.sh of the ci-scripts job, test_active_version.py and test_merge_assets.py (1028 checks, 200 seeded pairs). mdbook build has no ERROR line and no orphan page (with mdbook-mermaid not installed, so its preprocessor was switched off for the check).

Mutation: the scripts of this PR were broken one exact way each, 46 times by hand, and every mutant fails its own test. One survived at first (the link-text check in unpack-bundle.sh, which the type-letter check made redundant), and now has its own case. The driver is not in the repo, so CI does not re-run them (G-36).

Not verified, and what settles it

None of this has run against a real Cloudflare account, so these are open until the first staging deploy and the drill:

  • the JSON shapes of wrangler deployments list --json and wrangler versions list --json
  • the attestation round trip, gh attestation verify against a real bundle built on main
  • the token's scopes (Queues in particular), and a queue consumer with a dead-letter queue
  • GITHUB_TOKEN reading an environment's protection rules
  • the route through the Access tunnel, and verify-ca against a real Origin CA leaf
  • GNU tar's listing in unpack-bundle.sh (the tests ran on macOS tar; this PR's CI is the first run on GNU tar)

Left for the owner after this merges: infrastructure issues 1015 to 1017, the environments' variables and secrets, then the first deploy with first_deploy_skip_smoke and the injected-failure drill (deploy.md).

🤖 Generated with Claude Code

aRustyDev and others added 3 commits November 14, 2026 13:50
…ploy down

The deployed Worker now serves the web app, and a deploy keeps the web files of the release before it.

ADR-0011 has a missing hashed file answered 200 text/html (the single-page fallback), so a tab opened on release N-1 that asks for one of its scripts after release N has gone out gets HTML where it expected JavaScript. Each deploy therefore uploads the new release's files and the previous release's, never more than those two.

- wrangler.deploy.toml gets [assets] (single-page fallback, the same run_worker_first list as worker-dev.sh); the parity test checks both.
- The build job builds the web app and puts it in the attested bundle with the Worker.
- The deploy fetches the previous release's bundle from the artifacts API (unexpired, from a run on main, newest), verifies its attestation, unpacks it with a script that refuses links, special files, absolute and .. paths and another commit's BUILD_SHA, and merges the two sets of files (merge-assets.sh). A previous release it cannot read is a failure, except where the first deploy has none.
- After the smoke, a control asks the deployed Worker for scripts only the previous release had and requires JavaScript with the previous release's bytes; a failure rolls back like a failed smoke. The checker is shown to flag a text/html answer.
- GH_TOKEN is withheld from wrangler, the smoke and the expand step, as the Cloudflare secrets are from the fetch.
- docs/src/architecture/deploy.md is the runbook (environments, first deploy, ordinary and DO-lifecycle deploys, the rollback drill, rolling back by hand, rotating the token); cicd.md and infra.md say what is deployed now; ADR-0110 and ADR-0101 and QUESTIONS.md record the round-30 answers, including that GitHub OIDC was not achieved and a scoped API token stands in; G-36 records what is covered only against stand-ins.

The staging run is still to do: it needs the infrastructure repo's issues 1015 to 1017, the owner's variables and secrets, and the first deploy with first_deploy_skip_smoke. The issue stays open: acceptance criteria 2, 4 and 5 are runtime controls on staging, shown so far only against stand-ins.

Refs: #49
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The merge of main brought in the deletion of RL_CREATE (its binding, its variable and its namespace id), which left the runbook asking for a variable the renderer no longer knows and for three rate-limit namespaces where two are used.

Refs: #49
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 91f1d74 into main Nov 14, 2026
40 checks passed
@aRustyDev
aRustyDev deleted the feat/deploy-assets-and-docs branch November 14, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant