Repository navigation
ci: deploy a preview of each labelled PR - #289
Open
acoyfellow wants to merge 3 commits into
Open
acoyfellow wants to merge 3 commits into
acoyfellow wants to merge 3 commits into
Conversation
A maintainer adds the preview label to deploy the PR head to pr-<number>.<suffix> on a preview account. The workflow checks the server answers with 401, comments the URL on the PR, and deletes the Worker when the PR closes. New commits remove the label, so each update needs a fresh review. The MCP host allowlist also accepts the HTTPS hostname in MCP_RESOURCE, so a deployment trusts only its own hostname.
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.
Deploys a preview of a PR so the team can test it before release, with real accounts and no local setup.
How it works
previewlabel. The workflow deploys the PR head ascloudflare-api-mcp-pr-<n>onpr-<n>.<PREVIEW_DOMAIN_SUFFIX>, checks that/mcpanswers 401 without a token, and comments the URL and acodex mcp addline on the PR.MCP_RESOURCE. Each deployment trusts only its own hostname. Production and staging behave as before.Security
pull_request_targetruns PR code with the deploy secret, so deploys run only on thepreviewlabel, which only maintainers can add.npm ci --ignore-scriptskeeps install scripts from running. The config script is read from the base branch, not the PR.workers.devor preview URLs. They hold no Cloudflare credential of their own: every call uses the tester's token.Setup (one time, for maintainers)
PREVIEW_DEPLOY_TOKEN: Workers Scripts Edit and Workers Custom Domains Edit on the preview account.PREVIEW_ACCOUNT_ID,PREVIEW_DOMAIN_SUFFIX(a zone on that account),PREVIEW_KV_ID,PREVIEW_BUCKET(seeded withscripts/seed-r2.ts).pr-*.<suffix>.Verified on acoyfellow/mcp
previewlabel added: run 38584100072 deployedhttps://pr-2.mcp-preview.ax.cloudflare.dev/mcpand commented the URL.initialize200,tools/listincludesshow_attentionwith its UI resource, andshow_attentionreturned the real items on a test account. Codex CLI called the tool through it.wrangler deployments listsays it doesn't exist), and the URL stopped answering.npm test486 passed, plus a newtests/mcp-deployed-host.test.ts.tsc,format:check,lint(1 warning, also on main) andactionlintpass.