Repository navigation
ci: manage repository rulesets as code and combine the main rulesets - #572
Merged
Merged
Conversation
Check the rulesets into .github/rulesets/ so changes to them are reviewed as pull requests, and replace the two overlapping rulesets on main with a single protect-main ruleset. - .github/rulesets/protect-main.json: deletion, non-fast-forward, PR with 1 approval, and the build-and-test check, exported from the live rulesets. Merge methods are limited to squash and rebase to match the repo settings; nothing else changes. - hack/apply-rulesets.sh: applies the files (admin), with --dry-run, --check for CI, and --export. It matches rulesets by name and never deletes live rulesets. - .github/workflows/rulesets.yml: prints the diff on PRs that touch the rulesets, and fails daily when the live rulesets drift from the files. - docs/rulesets.md: what is enforced and how to change it. Fixes #548. Part of #547.
mayawang
approved these changes
Nov 12, 2026
mayawang
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, really glad to have the rulesets reviewable and drift-checked. Happy to run the apply script after merge
Collaborator
Author
|
@mayawang these should be ready to apply as you like! |
Collaborator
|
Ran the dry-run, looks right. One thing for step 3: the live "main: require PR review and CI" lets repo admins bypass via PR (RepositoryRole 5, pull_request mode), which you couldn't see. Could you add that to protect-main.json so we keep it? I'll apply once that's in |
Lukeluds
pushed a commit
to Lukeluds/ax-images
that referenced
this pull request
Nov 18, 2026
Keep the repository rulesets in .github/rulesets/ so a change to branch or tag protection is proposed and reviewed like any other change. - Export the two live rulesets, "Protect main" and "protect-tags", as they are today. Nothing about what is enforced changes. - Add scripts/apply-rulesets.sh to apply the files (matched by name), show differences (--dry-run), check for drift (--check) and export (--export). - Add the rulesets workflow: a dry run on pull requests that touch the rulesets, and a daily drift check. - Document the rulesets and how to change them in docs/rulesets.md. Ported from google/ax (hack/apply-rulesets.sh, google/ax#572). Part of agentexecutor#14.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves AX's repository rulesets into the repo, and replaces the two overlapping rulesets on
mainwith a singleprotect-main. This is the base of the rulesets stack for #546:protect-main(Combine the main rulesets into a single protect-main ruleset #548, part of Manage rulesets as code and protect release tags and branches #547)main(Set up a merge queue on main #571)Changes
.github/rulesets/protect-main.json: exported from the two live rulesets (mainandmain: require PR review and CI) and merged into one. The only change in policy:allowed_merge_methodsdropsmerge, which the repo settings already disable.hack/apply-rulesets.sh: syncs the files with GitHub. Rulesets are matched by name, and the script never deletes a live ruleset.--dry-run: print the diff--check: diff, and exit 1 on drift--export: write the live rulesets to the files.github/workflows/rulesets.yml: on PRs that touch the rulesets, prints the--dry-rundiff. Daily and on manual dispatch, runs--check, which fails on drift.docs/rulesets.md: what is enforced, how to change a ruleset, and how drift is reported. Linked from CONTRIBUTING.md. AGENTS.md is updated to match.Testing
Run locally against the live repo (read-only, as a non-admin):
After merge (repo admin)
hack/apply-rulesets.sh --dry-run, thenhack/apply-rulesets.sh. This createsprotect-main. It isactive, but it adds nothing stricter than the existing rulesets.mainandmain: require PR review and CIin Settings → Rules → Rulesets.bypass_actors: []matches what you want. Non-admins can't see the current bypass list, so it couldn't be exported.Until step 2 is done, the daily drift check fails, because the two old rulesets have no file.
Fixes #548. Part of #547.