Repository navigation
feat: deploy-cloudflare — publish private sites to a Worker behind Access, and prove they are gated (#163) - #176
Conversation
…#163) Work in progress, not yet ready for review. In this commit: - deploy-cloudflare/action.yml: validates inputs, checks the Access gate before uploading (refuses a missing, public or wrongly gated Worker), sets up Node only if <22, installs wrangler with npm ci from the committed lockfile, writes a wrangler.jsonc into RUNNER_TEMP, deploys, checks the gate after the deploy (root + one non-HTML asset), uploads and checks an optional preview alias, and writes a job summary. - deploy-cloudflare/package.json + package-lock.json: wrangler 4.136.3. - scripts/check-access-gate.sh: the pilot's probe, generalised to several URLs; exact team-domain match, loud failure on 2xx, no -L. - .github/fixtures/access-gate/server.py: local stand-in for each gate response shape, for the harness. Still to do: harness jobs, README/CHANGELOG/TESTING/dependabot docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JxLZgJNNxNmNmeUUiD3SBW
…#163) - deploy-cloudflare/write-config.js: the generated wrangler config, moved out of an inline `node -e` so the harness dry-runs the exact file the action uses. - test-actions.yml: dc-gate-probe (every gate response shape against a local stand-in), dc-refuses-ungated (an ungated Worker is refused before wrangler is installed), dc-inputs (every invalid input fails in validation), dc-wrangler-config (the pinned wrangler accepts the generated config); all wired into harness-summary. - dependabot.yml: npm ecosystem for /deploy-cloudflare; the directory is added to the github-actions list for actions/setup-node. - deploy-cloudflare/README.md with the setup checklist; README, CHANGELOG, TESTING, QUICK-REFERENCE, ARCHITECTURE and copilot-instructions entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JxLZgJNNxNmNmeUUiD3SBW
…ailed deploy (#163) From an adversarial review of the branch: - Every deploy gets its own preview URL (preview_urls: true), which no check covered when no alias was given. The check after deploying now probes https://<version>-<worker>.<subdomain>.workers.dev too, from the "Current Version ID" wrangler prints, and fails closed if it is missing. - wrangler can exit non-zero after the new version is live, which used to skip the check after deploying. It now runs whenever wrangler was attempted, and the summary says the build may be live. - check-access-gate.sh refuses an empty or malformed team domain (exit 2; an empty team matched a Location-less 302) and a Location whose host is hidden behind userinfo or a backslash. - build-dir may not contain line breaks, which would inject outputs. - Harness: dc-inputs sets require-access: 'false' on every case but one, so a dropped validation rule cannot hide behind the gate check; dc-refuses-ungated gains a positive control showing the same inputs reach wrangler with the gate off; dc-wrangler-config fails on wrangler's "Unexpected fields" warning; dc-gate-probe covers the new cases. - Docs brought in line: require-access covers every check, troubleshooting names every refusal message, copilot-instructions counts 8 actions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JxLZgJNNxNmNmeUUiD3SBW
…angler pipeline (#163) From a second review of the fix commit: - The runner starts steps with `bash -e`, so a failing `wrangler deploy | tee` ended the step before the exit status, the version id and the ::error:: annotation were read. The pipeline now runs under `set +e`. - A missing "Current Version ID" now fails the check after deploying in every case, not only after a successful deploy: wrangler prints the id only once every post-upload step has succeeded, so most failed deploys lack it, and the version's preview URL was then skipped silently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JxLZgJNNxNmNmeUUiD3SBW
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It introduces a large, security-critical new action that gates private content, and its real-deploy path against a gated Worker with a per-Worker Editor token is explicitly unexercised in CI, so a human should verify that path before approval.
Review effort: Balanced
Findings: None
What changed in this PR
This PR adds a new composite action, deploy-cloudflare, that publishes a built site to an existing Cloudflare Worker behind Cloudflare Access and fails the job unless the site is provably gated (an unauthenticated request must redirect to exactly the configured <team>.cloudflareaccess.com). It complements the existing PR-only preview-cloudflare and fills the "members-only site" gap that GitHub Pages cannot cover on the org's Team plan. The action validates inputs, checks the gate before uploading (fail-closed prevention), installs a lockfile-pinned wrangler, generates a per-run config, deploys, and re-checks the gate on production, the new version's preview URL, and any alias — writing a job summary in every outcome.
Changes:
- New action:
deploy-cloudflare/(action.yml,write-config.js, pinnedpackage.json/package-lock.json, README) plus the sharedscripts/check-access-gate.shprobe. - CI: four harness jobs (
dc-gate-probe,dc-refuses-ungated,dc-inputs,dc-wrangler-config) wired into the requiredAction harness: all checks, with a local Python gate stand-in fixture; Dependabot gains an npm ecosystem entry for the wrangler lockfile. - Docs: README, QUICK-REFERENCE, ARCHITECTURE, TESTING, CHANGELOG and copilot-instructions updated for the new action.
| File | Description |
|---|---|
deploy-cloudflare/action.yml |
Core composite action: input validation, gate checks before/after deploy and on alias, tee'd wrangler deploy, job summary. |
scripts/check-access-gate.sh |
Probe that passes only a redirect to the exact team domain; handles 2xx/404/5xx, userinfo/backslash, unreachable, empty team. |
deploy-cloudflare/write-config.js |
Generates the minimal per-run wrangler config (assets-only, workers_dev + preview_urls). |
deploy-cloudflare/package.json / package-lock.json |
Pins wrangler 4.136.3 for npm ci. |
deploy-cloudflare/README.md |
Usage, inputs/outputs, gate-check semantics, setup checklist, troubleshooting. |
.github/workflows/test-actions.yml |
Four new harness jobs + anchor needs wiring. |
.github/fixtures/access-gate/server.py |
Local stand-in emitting each gate response shape for the probe test. |
.github/dependabot.yml |
Adds /deploy-cloudflare to github-actions dirs and a new npm ecosystem block. |
README.md, docs/QUICK-REFERENCE.md, docs/ARCHITECTURE.md, TESTING.md, CHANGELOG.md, .github/copilot-instructions.md |
Documentation and inventory updates for the new action. |
Files not reviewed (1)
- deploy-cloudflare/package-lock.json: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…4xxo7v Resolves the two conflicts with main after #173 and #175 landed: the copilot-instructions status block keeps main's refreshed release and container lines with this branch's "8 composite actions" line, and the CHANGELOG's [Unreleased] Added section carries both sets of entries. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ploy Resolves the conflicts with #176: test-actions.yml keeps the four deploy-cloudflare harness jobs and this branch's preview-cli-install job, with all five in harness-summary's needs; TESTING.md keeps the deploy-cloudflare row and this branch's split of the preview-* and publish-gh-pages rows. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
First live run: QuantEcon/project-qep7A live deploy has now answered both points under Not verified here. QuantEcon/project-qep7 became the first consumer, ahead of QuantEcon/status-projects#107. Its end-to-end test is recorded on QuantEcon/project-qep7#7.
Still not exercised: the Assisted-by: Claude Code (Claude Opus 5.5) |
Closes #163.
Adds
deploy-cloudflare, a new action that publishes a built site to an existing Cloudflare Worker behind Cloudflare Access and fails the job unless the site is proven gated. It runs onpush,scheduleandworkflow_dispatch.preview-cloudflareis untouched and stays PR-only.What it does
worker-name,account-subdomainandaliasmust be valid hostname labels, since the URLs are built from them.team-domainmust be a*.cloudflareaccess.comlogin domain.require-accessmust be exactlytrueorfalse.build-dirmust exist and hold files. An empty token is reported as the fork/Dependabot case.https://{worker}.{subdomain}.workers.dev/must be redirected to exactlyteam-domain. If it isn't, the action refuses and nothing is uploaded. This covers a Worker that doesn't exist (a mistyped name, which a token broader than the README's would otherwise create, ungated), one that is public, and one gated by the wrong Access organisation.npm cifromdeploy-cloudflare/package-lock.jsonintoRUNNER_TEMP. Node 24 is set up only if the runner has less than 22.write-config.jswrites{name, compatibility_date, assets.directory, workers_dev, preview_urls}, thenwrangler deploy --configruns. wrangler's output is teed to the log rather than captured into a variable, so its errors reach the log (fix(preview): surface deploy errors, pin CLIs, remove unsafe fork guidance #105).https://<version>-{worker}.{subdomain}.workers.dev. Every deploy gets one, because the config enables preview URLs, and an Access setup covering only the production hostname would leave it public. The address comes from wrangler'sCurrent Version IDline, and the check fails closed if that line is missing. The check also runs whenwrangler deployfails, because wrangler can exit with an error after the new version is already live.alias, it runswrangler versions upload --preview-aliasand then checks the alias URL's gate.Each gate check probes the root and one real non-HTML file from the build, so a gate that covers only the document root can't pass.
scripts/check-access-gate.shis the probe from the #163 comment, generalised to several URLs:Locationhost equals the team domain.2xxgets its own loud "THE SITE IS PUBLIC" failure.404,5xx, same-host redirects, a missingLocation, aLocationhiding its host behind userinfo or a backslash, and unreachable hosts all fail closed.Decisions (settled in review of #163)
/deploy-cloudflare./deploy-cloudflareis also added to the github-actions directories, foractions/setup-node.custom-domaininput. Domains stay in the dashboard, and the generated config declares no routes, so wrangler leaves them alone (checked in wrangler 4.136.3'striggersDeploy).2026-08is invalid. Cloudflare requires an alias to start with a lowercase letter, and wrangler doesn't check before uploading. The action validates this up front, and the docs usereport-2026-08.Tests
Four new harness jobs, all wired into
Action harness: all checks. None needs a Cloudflare account:dc-gate-probe.github/fixtures/access-gate/server.py), passes only a redirect to the exact team domain. It fails on a wrong org, a public2xx, a same-host redirect, noLocation, aLocationhiding its host behind userinfo,404,5xx, an unreachable host, an empty team domain, and a public asset behind a gated root, and each failure prints the expected message.dc-refuses-ungatedworkers.devWorker is refused, and$RUNNER_TEMP/deploy-cloudflarenever exists, so wrangler was never even installed. A positive control then runs the same inputs with the gate off: they reach the wrangler install and the config, which proves the refusal came from the gate check.dc-inputsdeploy-url, and nothing is installed. Six cases run with the gate off, so a validation rule that went missing can't hide behind the gate check.dc-wrangler-configwrite-config.js's output fordeploy --dry-runandversions upload --preview-alias --dry-run, with noUnexpected fieldswarning. This is the check a Dependabot bump of the lockfile runs against.Two adversarial review passes ran over the branch before this PR: five reviewers across security, composite mechanics, the harness, docs and wrangler behaviour, then two reviewers on the fix commit, with every finding checked by an independent skeptic. The last two commits fix what survived.
The most significant fixes:
302with noLocation.Locationcould hide its real host behind userinfo.bash -eabort at thewrangler | teepipeline skipped the error handling.Verified locally before pushing:
require-access: false;dc-gate-probescript passes, and fails when an expectation is deliberately wrong.run:block.main.Not verified here
collect.yml, QuantEcon/status-projects#107) is its proof. The part I'm least sure of is whether wrangler's deploy path succeeds with a per-Worker Editor token. wrangler 4.136.3 tolerates an unauthorised account-levelworkers/subdomainlookup in some paths, but I couldn't exercise it.Current Version IDline format was confirmed against wrangler 4.136.3's source, but not against a live deploy's output.🤖 Generated with Claude Code
https://claude.ai/code/session_01JxLZgJNNxNmNmeUUiD3SBW
Generated by Claude Code