Skip to content

ci(rulesets): manage rulesets as code and require the existing checks - #27

Merged
jdwillmsen merged 2 commits into
mainfrom
chore/rulesets-as-code
Aug 2, 2026
Merged

ci(rulesets): manage rulesets as code and require the existing checks#27
jdwillmsen merged 2 commits into
mainfrom
chore/rulesets-as-code

Conversation

@jdwillmsen

Copy link
Copy Markdown
Member

What

Adds .github/rulesets/ — exports of both live rulesets plus the apply.sh the other four repositories use — and requires the four status checks that already run on every pull request.

Why

This was the last of the five repositories keeping its branch rules only live. The other four keep them as reviewable JSON, so a rule change shows up in a diff. Here there was nothing in git to review, nothing to reapply after an accidental UI edit, and no record of the previous state.

It is also not low-stakes. This repository holds the reusable workflows every other repository calls by @mainsecurity-scan.yml, verify-pr-signatures.yml, the release workflows — plus the org-wide gitleaks.toml. Its gates protect all five repos, and main had zero required checks: any pull request could merge with every scan and signature job red as long as it carried one approving review.

Commits

  1. manage branch rulesets as code — faithful exports of the two live rulesets and apply.sh. No behaviour change; both apply as no-ops.
  2. require the checks — adds required_status_checks to Baseline.

Split so the snapshot can be reviewed as a snapshot rather than read as part of the change.

Which checks, and why only these

scan / scan          scan / gitleaks
scan / binaries      signatures / signatures

All four are published by the github-actions app (integration_id: 15368), pinned so a same-named check from another app cannot satisfy the rule.

Trivy is deliberately excluded. It is published by the code-scanning app from a SARIF upload rather than by the workflow, so it can simply not appear — and a required check that never appears blocks the branch permanently with nothing red to fix.

Each context was traced to its workflow before being required. security-scan-self.yml and verify-pr-signatures-self.yml both trigger on a bare pull_request with no paths: filter. Two of the underlying jobs — binaries and signatures — do carry if: github.event_name == 'pull_request', which is safe: a guard toward pull_request always fires when required checks are evaluated. The fatal pattern is the inverse (== 'push'), which reports skipping on a pull request and would deadlock main.

strict_required_status_checks_policy is false, matching platform, infrastructure and deployments. With it on, every merge to main invalidates the checks on every other open pull request.

Verification

Export round-trips against the existing rulesets rather than recreating them:

$ ./apply.sh --dry-run
would PUT repos/jdwlabs/.github/rulesets/17653724  (Baseline from baseline.json)
would PUT repos/jdwlabs/.github/rulesets/17653722  (Branch Naming Convention from branch-naming-convention.json)
done: 2 ruleset file(s) processed for jdwlabs/.github
  • branch-naming-convention.json is byte-identical to live after normalisation
  • baseline.json differs from live only inside .rules, by exactly the added required_status_checks
  • apply.sh differs from the deployments copy only in REPO (plus a corrected re-export hint)

Not included

required_signatures. Not added, deliberately. It would be inert here for the same reason it is inert elsewhere in the org: rebase-merge rebuilds every commit server-side and signs none of them, so the rule cannot enforce what it claims. Adding an enforcement that cannot enforce is worse than its absence, because it reads as covered.

After merge

apply.sh must be run by hand — there is no drift job, so merging this alone changes nothing live.

The other four repositories keep their rulesets in .github/rulesets/*.json
with an apply.sh, so a rule change is a reviewable diff. This one had no
such directory: its rules existed only live, with nothing in git to review,
nothing to reapply after an accidental UI edit, and no record of what the
rules were beforehand.

Both files are faithful exports of the current live rulesets and apply as
no-ops. apply.sh is the deployments copy with REPO retargeted.
main had zero required status checks, so a pull request could merge with
every scan and signature job red provided it carried one approving review.
This repository holds the reusable workflows the other four call by @main,
so its gates protect all of them.

Requires only the four checks that report unconditionally. Trivy is excluded
deliberately: it is published by the code-scanning app from a SARIF upload
rather than by the workflow, so it can simply not appear, and a required
check that never appears blocks the branch permanently.
@jdwillmsen
jdwillmsen merged commit 53d6d9c into main Aug 2, 2026
5 checks passed
@jdwillmsen
jdwillmsen deleted the chore/rulesets-as-code branch August 2, 2026 04:40
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.

1 participant