lock-release.yml: Use legacy branch protection instead of rulesets#7705
lock-release.yml: Use legacy branch protection instead of rulesets#7705liuliu-dev merged 3 commits intomainfrom
Conversation
|
There was a problem hiding this comment.
Pull request overview
Updates the release-lock GitHub Actions workflow to lock/unlock the main branch by calling the Branch Protection API, aiming to prevent merges during releases while fixing prior API validation issues.
Changes:
- Replace prior ruleset toggling with
PUT /branches/main/protectioncalls using JSON--input. - Lock
mainvialock_branch: trueand configure push restrictions for thereact-release-conductorteam. - Unlock
mainvialock_branch: falseand remove restrictions viarestrictions: null.
Comments suppressed due to low confidence (1)
.github/workflows/lock-release.yml:83
- The unlock step also sends
required_status_checks: null,required_pull_request_reviews: null, andenforce_admins: false, which will leave main with weakened/disabled protection settings after the release lock is removed. If the intent is to only unlock the branch, this should restore (or preserve) the repo’s pre-existing protection settings rather than resetting them to null/false.
/repos/primer/react/branches/main/protection \
--input - <<EOF
{
"lock_branch": false,
"restrictions": null,
"required_status_checks": null,
"enforce_admins": false,
"required_pull_request_reviews": null
}
| /repos/primer/react/branches/main/protection \ | ||
| --input - <<EOF | ||
| { | ||
| "lock_branch": true, | ||
| "restrictions": { | ||
| "teams": ["react-release-conductor"], | ||
| "users": [] | ||
| }, | ||
| "required_status_checks": null, | ||
| "enforce_admins": true, | ||
| "required_pull_request_reviews": null | ||
| } |
There was a problem hiding this comment.
This PUT /branches/main/protection payload explicitly sets required_status_checks and required_pull_request_reviews to null, which disables those protections (and because this is a full update, it can overwrite the branch’s existing protection configuration). If main currently relies on required checks/reviews, running the lock will unintentionally turn them off. Consider fetching the current protection config first and re-sending it with only lock_branch/restrictions adjusted (or otherwise preserving the existing required checks/review settings).
This issue also appears on line 75 of the same file.
Problem
If the main branch is locked by rulesets, enabling auto merge on a pull request says it will be merged. But it's not merged when the main branch is unlocked.
This is because auto merge is not reevaluated when the rule set changes.
Solution
Moved the lock-release workflow to legacy branch protection instead of rulesets because auto-merge still works with branch protection.
Tested the workflow by running from this branch
lock_branch: trueClassic branch protection does not use "bypass", so I had to give write access to the release conductor role, which feels okay because they already do.