Skip to content

feat: Add option to overwrite branch name for deployments#776

Merged
andykenward merged 9 commits into
mainfrom
claude/option-to-overwrite-branch-name
Jun 3, 2026
Merged

feat: Add option to overwrite branch name for deployments#776
andykenward merged 9 commits into
mainfrom
claude/option-to-overwrite-branch-name

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Jun 3, 2026

Summary

Adds an optional branch input 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's main branch is auto-detected as main and 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

  • branch input — declared in action.yml, keyed in input-keys.ts, read in src/deploy/inputs.ts (empty string normalised to undefined), threaded through src/deploy/main.ts into src/common/cloudflare/deployment/create.ts as branchOverride ?? contextBranch, then passed to wrangler pages deploy --branch.
  • Docs — added a "Custom branch name" section to README.md and the input to the Inputs table. The fork example uses the reliable artifact-passing pattern (save the PR number in the pull_request workflow → read it in the workflow_run workflow) because github.event.workflow_run.pull_requests is empty for fork PRs (community #25220).
  • Cleanup — removed the vestigial peerDependencies.wrangler from package.json. It had no consumer (private package, esbuild-external, runtime uses npx wrangler@<version>) and was drifting from devDependencies.wrangler (the single source of truth that bin/sync-versions.ts propagates to inputs.ts).
  • AGENTS.md — documented the workflow_run fork-PR gotcha, clarified the optional-vs-required input testing flow, and corrected the wrangler "peer dependency" wording.

Testing

Changeset

minor.changeset/ripe-yaks-argue.md

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 3, 2026

🦋 Changeset detected

Latest commit: 945c630

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
github-actions-cloudflare-pages Minor

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

@Claude Claude AI linked an issue Jun 3, 2026 that may be closed by this pull request
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>
@Claude Claude AI requested a review from andykenward June 3, 2026 18:06
Signed-off-by: Andy Kenward <4893048+andykenward@users.noreply.github.com>
@andykenward andykenward marked this pull request as ready for review June 3, 2026 18:18
andykenward

This comment was marked as outdated.

@andykenward andykenward changed the title [WIP] Add option to overwrite branch name for deployments feat: Add option to overwrite branch name for deployments Jun 3, 2026
@andykenward andykenward merged commit b458526 into main Jun 3, 2026
8 checks passed
@andykenward andykenward deleted the claude/option-to-overwrite-branch-name branch June 3, 2026 19:01
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.

Option to overwrite branch name?

2 participants