Repository navigation
Description
Summary
Since v1.2.1, push_to_pull_request_branch fails on every non-default branch in repositories covered by an organisation ruleset, including a purely required_signatures ("Signed Commits") ruleset. check-branch-protection is now effectively "block if any ruleset applies", so orgs that enforce signed commits can only use push-to-pull-request-branch by disabling the protection check entirely. That also drops the guard for default-branch-style protection (required reviews, status checks, etc.), which we want to keep.
Observed failure (gh-aw v1.2.2)
safe_outputs job log:
Check branch protection: true
Push signed commits: true
##[error]Cannot push to branch "fix/some-feature-branch": this branch has protection rules. Agents must not push directly to protected branches.
The push is never attempted. signed-commits was enabled, so a signed commit would have satisfied the rule.
Root cause
checkBranchPushable in actions/setup/js/pr_helpers.cjs, changed in #74946 (commit 3636e00e6, first released in v1.2.1; absent in v1.2.0):
- await githubClient.rest.repos.getBranchProtection({ owner, repo, branch: branchName });
- // Successful response means branch protection rules exist
- isBranchProtected = true;
+ const { data: branchData } = await githubClient.rest.repos.getBranch({ owner, repo, branch: branchName });
+ isBranchProtected = branchData.protected;- Up to v1.2.0 the guard used
getBranchProtection, which returns 404 unless classic branch protection exists. Rulesets were ignored. - From v1.2.1 it reads
branch.protected, which is alsotruewhen any ruleset applies to the branch. - Fix PR branch rejection for Copilot-review-only rulesets #75230 added
hasOnlyCopilotReviewRulesso branches whose only rules arecopilot_code_revieware not treated as protected. No other rule type is exempt.
Reproduction
Repo with an org-level ruleset: required_signatures, target ~ALL, enforcement active, no classic branch protection.
$ gh api repos/OWNER/REPO/branches/some-feature-branch --jq '{protected,protection}'
{"protected":true,"protection":{"enabled":false,"required_status_checks":{"checks":[],"contexts":[],"enforcement_level":"off"}}}
$ gh api repos/OWNER/REPO/rules/branches/some-feature-branch --jq '.[].type'
required_signatures
branch_name_pattern
file_extension_restriction
Any workflow using safe-outputs.push-to-pull-request-branch with default check-branch-protection then fails on any PR branch. We confirmed an unrelated feature branch in the same repo also reports protected: true.
Impact
- Organisations that enforce signed commits (a common baseline) cannot use
push-to-pull-request-branchwith the default guard on any PR branch since v1.2.1. - The only workaround is
check-branch-protection: false, which removes the protection guard wholesale, including for branches with real protection (required reviews or checks, lock branch, etc.). We would rather keep the guard and only exempt rules a signed append-only push satisfies. - The failure surfaces only in the post-agent safe_outputs job, after the agent has finished work. Agents report the push as "requested", so it is easy to miss.
Proposed fix
Make the guard distinguish rules that block an agent push from rules that an append-only (optionally signed) push to a PR branch satisfies. In checkBranchPushable, when branchData.protected is true and branchData.protection?.enabled === false, extend hasOnlyCopilotReviewRules (it already reads repos.getBranchRules) to an allowlist of non-blocking rule types:
copilot_code_review(existing)required_signatures, but only when the safe output is configured with signed commits, as the push then satisfies the rule- naming, content and metadata rules that a normal push satisfies:
branch_name_pattern,commit_message_pattern,commit_author_email_pattern,committer_email_pattern,file_path_restriction,file_extension_restriction,max_file_path_length,max_file_size
Keep blocking, as today, on rules that mean the branch is genuinely protected: update, deletion, non_fast_forward, pull_request, required_status_checks, required_deployments, merge_queue, required_linear_history, workflows, etc. Keep the existing classic-protection confirmation (refUpdateRule).
Optionally expose the allowlist in frontmatter for overrides, for example push-to-pull-request-branch.allowed-rule-types: [...], instead of an all-or-nothing check-branch-protection: false.
Implementation plan
actions/setup/js/pr_helpers.cjs: replacehasOnlyCopilotReviewRuleswithhasOnlyNonBlockingRules(githubClient, owner, repo, branch, { signedCommits })using the allowlist above. Keep paging and fail-closed behaviour.- Plumb
signed-commitsintocheckBranchPushable's options. Check the call sites in thepush_to_pull_request_branchhandler. - Tests in the existing
pr_helperstest file:- only
required_signatures+signedCommits: true→ pushable - only
required_signatures+signedCommits: false→ blocked required_signatures+pull_request→ blockedrequired_signatures+branch_name_pattern→ pushable- classic protection enabled → blocked
- only
- Update the
check-branch-protectiondocs forpush-to-pull-request-branchto state which rule types are treated as non-blocking.
Acceptance criteria
A repo whose only branch rules are org-level required_signatures (plus naming/content rules) can use push-to-pull-request-branch with signed-commits enabled and the default check-branch-protection, while branches with required reviews, status checks or classic protection are still blocked.
Environment
- gh-aw v1.2.2 (also v1.2.1); v1.2.0 and earlier behave correctly
- Engine: copilot
- Repo covered by org rulesets (
required_signatures,branch_name_pattern,file_extension_restriction), classic branch protection off
Activity