Skip to content

ci: manage repository rulesets as code - #23

Merged
MushuEE merged 3 commits into
mainfrom
ci/rulesets-as-code
Nov 18, 2026
Merged

MushuEE merged 3 commits into
mainfrom
ci/rulesets-as-code

Conversation

@MushuEE

@MushuEE MushuEE commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Part of #14, under the release epic #12.

What

Keeps the repository rulesets in the repo, so a change to branch or tag protection is proposed and reviewed like any other change. Ported from google/ax (google/ax#572).

  • .github/rulesets/: the two live rulesets, Protect main and protect-tags, exported as they are today. Nothing about what is enforced changes.
  • scripts/apply-rulesets.sh: applies the files to GitHub, matched by name. --dry-run shows differences, --check fails on drift, --export writes the live rulesets to the files. It never deletes a live ruleset.
  • rulesets workflow: a dry run on pull requests that touch the rulesets, and a daily drift check.
  • docs/rulesets.md: what is enforced and how to change it.

What is enforced today

Ruleset Applies to Rules Who can bypass
Protect main main No deletion or force-push. A pull request with 1 approving review, cleared on a new push. The License headers check must pass. Organization admins
protect-tags All tags Tags can't be created, moved or deleted, and names must match vMAJOR.MINOR.PATCH[-PRERELEASE]. Repository admins

So release tags are already limited to repository admins, which is what the release workflow (#13) needs before it publishes.

After merge

Nothing to apply: the files match what is live. From then on, a ruleset change is a pull request to these files, followed by an admin running scripts/apply-rulesets.sh.

Testing

  • scripts/apply-rulesets.sh --export wrote both files from the live rulesets, and --check right after reports both as up to date.
  • scripts/verify/boilerplate.sh passes.
  • I did not run shellcheck or actionlint locally.

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 #14.
@MushuEE MushuEE added this to the Milestone v0.0.0 milestone Nov 18, 2026
@MushuEE MushuEE self-assigned this Nov 18, 2026
@MushuEE
MushuEE requested a review from Lukeluds November 18, 2026 01:35
@MushuEE MushuEE mentioned this pull request Nov 18, 2026
5 of 6 tasks
Split tag protection into the two rulesets ai-on-gke/substrate-gke uses:

- protect-tags-create: tags can't be created, except by repository admins.
- protect-tags-immutable: once created, a tag can't be moved or deleted by
  anyone, including admins.

The tag name pattern (vMAJOR.MINOR.PATCH[-PRERELEASE]) moves to the ruleset
with no bypass. In the single protect-tags ruleset, admins could bypass it,
and admins are the only ones who can create tags, so it never applied.

After merge, an admin runs scripts/apply-rulesets.sh to create the two
rulesets, then deletes the old protect-tags ruleset in the repository
settings.

Part of #14.
Lukeluds
Lukeluds previously approved these changes Nov 18, 2026
ci: make release tags immutable, as in substrate-gke
@MushuEE
MushuEE merged commit 030c920 into main Nov 18, 2026
4 checks passed
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.

2 participants