Skip to content

Migrate public-repo branch protection to GitHub Rulesets for admin force-push break-glass - #12

Merged
gavinbee merged 2 commits into
mainfrom
11-rulesets-admin-force-push
May 31, 2026
Merged

Migrate public-repo branch protection to GitHub Rulesets for admin force-push break-glass#12
gavinbee merged 2 commits into
mainfrom
11-rulesets-admin-force-push

Conversation

@gavinbee

Copy link
Copy Markdown
Contributor

Summary

  • Adds a rulesets: block to settings.yml defining a swimblocks-default ruleset with the same rules as the current legacy branch protection, plus bypass actors for org owners and repo admins
  • Updates apply-settings.py to route public repos to ruleset-based protection (creating/updating the ruleset and removing legacy branch protection) and private repos to the existing legacy path
  • Updates CONTRIBUTING.md to document rulesets as the mechanism for public repos and adds a "Force-push break-glass" section explaining that admins just run git push origin main --force

Why

Legacy branch protection has no per-actor bypass for force pushes — allow_force_pushes: false blocks everyone including org owners. GitHub Rulesets support bypass actors, giving admins a clean break-glass without any UI steps. The bypass is recorded in the GitHub audit log.

Immediate trigger: needed to complete a history rewrite on swimblocks/rems-sync (purging apps_script/ from history before the repo went public).

Test plan

  • Merge this PR (admin bypass via ruleset, since swimblocks/.github itself is a public repo)
  • Run scripts/apply-settings.py swimblocks/rems-sync — should create the ruleset, report OK ruleset 'swimblocks-default': present, and remove legacy branch protection
  • Confirm git push origin main --force succeeds on rems-sync as an admin (completing the history rewrite)
  • Trigger the reconciler workflow manually to confirm it applies cleanly to all public repos

Closes #11

🤖 Generated with Claude Code

gavinbee and others added 2 commits May 30, 2026 11:07
Closes #9.

Two updates triggered by review feedback on PR #6:

- Add a "code comments" rule: TODOs / aspirational comments must link
  to a GitHub issue, not float as bare wishes. Land in CONTRIBUTING.md
  with examples; mirror a short summary in AGENTS.md that points back.
- Add a core-principle bullet capturing the meta-pattern: when review
  yields a generalizable rule, fold it back into CONTRIBUTING.md via
  a PR closing a tracking issue. A verbal "I'll remember" doesn't bind
  future contributors (especially agents).

Also folds in the solo-admin merge path notes from PR #6's review
(admin-bypass via UI button or `gh pr merge --admin --squash`) so the
next contributor isn't blocked by the CODEOWNERS deadlock.

Renumbers AGENTS.md sections to keep them sequential after the new
"Code comments" section.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rce-push break-glass

Public repos now use a GitHub Ruleset instead of legacy branch protection. The ruleset
enforces the same rules (PR required, linear history, no force push for non-admins) but
adds bypass actors for org owners and repo admins — so `git push origin main --force`
works as a break-glass without any UI changes. GitHub records the bypass in the audit log.

Private repos continue to attempt legacy branch protection (expected SKIP on Free plan).

apply-settings.py: adds get_repo_visibility, list/apply/verify_ruleset,
delete_legacy_protection; routes public vs private repos to different protection paths.
settings.yml: adds `rulesets:` block with the canonical ruleset definition.
CONTRIBUTING.md: updates branch protection docs and adds Force-push break-glass section.

Closes #11

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@gavinbee gavinbee left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM

@gavinbee
gavinbee merged commit 18835aa into main May 31, 2026
@gavinbee
gavinbee deleted the 11-rulesets-admin-force-push branch May 31, 2026 04:18
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.

Migrate public-repo branch protection to GitHub Rulesets for admin force-push break-glass

1 participant