Skip to content

lock-release.yml: Use legacy branch protection instead of rulesets#7705

Merged
liuliu-dev merged 3 commits intomainfrom
fix-lock-release-workflow
Mar 26, 2026
Merged

lock-release.yml: Use legacy branch protection instead of rulesets#7705
liuliu-dev merged 3 commits intomainfrom
fix-lock-release-workflow

Conversation

@siddharthkp
Copy link
Copy Markdown
Member

@siddharthkp siddharthkp commented Mar 26, 2026

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 creates a branch protection rule that locks main with react-release-conductor as exception
  • unlocking deletes the branch protection rule
  • if release conductor exception works with lock_branch: true
  • auto merge works (tested this on a different repo, not in primer/react yet)

Classic 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.

@siddharthkp siddharthkp requested a review from a team as a code owner March 26, 2026 11:06
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 26, 2026

⚠️ No Changeset found

Latest commit: a8e5834

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added the staff Author is a staff member label Mar 26, 2026
@siddharthkp siddharthkp added the skip changeset This change does not need a changelog label Mar 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/protection calls using JSON --input.
  • Lock main via lock_branch: true and configure push restrictions for the react-release-conductor team.
  • Unlock main via lock_branch: false and remove restrictions via restrictions: 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, and enforce_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
          }

Comment on lines +39 to +50
/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
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@github-actions github-actions Bot temporarily deployed to storybook-preview-7705 March 26, 2026 11:16 Inactive
@siddharthkp siddharthkp changed the title Fix lock-release workflow: use lock_branch and proper JSON format lock-release.yml: Use legacy branch protection instead of rulesets Mar 26, 2026
Copy link
Copy Markdown
Contributor

@liuliu-dev liuliu-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! ❤️

@liuliu-dev liuliu-dev added the integration-tests: skipped manually Changes in this PR do not require an integration test label Mar 26, 2026
@liuliu-dev liuliu-dev merged commit f441841 into main Mar 26, 2026
84 of 85 checks passed
@liuliu-dev liuliu-dev deleted the fix-lock-release-workflow branch March 26, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: skipped manually Changes in this PR do not require an integration test skip changeset This change does not need a changelog staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants