feat: Add option to overwrite branch name for deployments#776
Merged
Conversation
🦋 Changeset detectedLatest commit: 945c630 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Add optional branch input to allow users to override the automatically detected branch name for Cloudflare Pages deployments. This is useful for workflow_run deployments where fork PRs based on main would otherwise overwrite the production deployment. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Agent-Logs-Url: https://github.com/andykenward/github-actions-cloudflare-pages/sessions/9a8b2519-3a11-4339-9046-06aab99972a1 Co-authored-by: andykenward <4893048+andykenward@users.noreply.github.com>
Signed-off-by: Andy Kenward <4893048+andykenward@users.noreply.github.com>
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.
Summary
Adds an optional
branchinput to the deploy action that overrides the branch name used for the Cloudflare Pages deployment. When unset, behaviour is unchanged — the branch is auto-detected from the GitHub context.Closes #775.
Why
With
workflow_run, a pull request opened from a fork'smainbranch is auto-detected asmainand deploys to the project's production branch, overwriting the production deployment. The new input lets you force a distinct branch name (e.g.pr-123) so each PR gets its own Cloudflare Pages preview instead.Changes
branchinput — declared in action.yml, keyed in input-keys.ts, read in src/deploy/inputs.ts (empty string normalised toundefined), threaded through src/deploy/main.ts into src/common/cloudflare/deployment/create.ts asbranchOverride ?? contextBranch, then passed towrangler pages deploy --branch.pull_requestworkflow → read it in theworkflow_runworkflow) becausegithub.event.workflow_run.pull_requestsis empty for fork PRs (community #25220).peerDependencies.wranglerfrom package.json. It had no consumer (private package, esbuild-external, runtime usesnpx wrangler@<version>) and was drifting fromdevDependencies.wrangler(the single source of truth thatbin/sync-versions.tspropagates toinputs.ts).workflow_runfork-PR gotcha, clarified the optional-vs-required input testing flow, and corrected the wrangler "peer dependency" wording.Testing
returns branch when provided/branch: undefineddefault — tests/deploy/inputs.test.tshandles branch overrideasserts the--branch pr-123wrangler invocation — tests/common/cloudflare/deployment/create.test.tspnpm install --frozen-lockfileclean; affected suites pass.Changeset
minor— .changeset/ripe-yaks-argue.md