Sub topic 14
Rolling out safely and reviewing rule insights
A ruleset that blocks merges in every repository can stop dozens of teams at once if it is wrong. This chapter covers how to introduce an organisation ruleset in stages. It also covers how to read the evidence that GitHub records about each rule evaluation.
This chapter assumes you can already write an organisation ruleset as JSON and know the enforcement statuses (active, evaluate, disabled). It also assumes you know how bypass actors work and how a required workflow is configured. You should be comfortable with gh api and with reading JSON.
Why staged rollout matters
Every rule you add changes what developers can do. Common surprises include:
- A required workflow that fails on repositories with an unusual layout.
- A pull request rule that blocks a release bot that pushes directly.
- A
~DEFAULT_BRANCHtarget that hits repositories you forgot existed. - A code owner review requirement in repositories that have no
CODEOWNERSfile.
You can predict some of these by reading the configuration. You find the rest by watching real pushes and pull requests. Evaluate mode and rule insights give you that view without blocking anyone.
The rollout stages
A safe rollout changes one variable at a time: the enforcement status first, then the set of repositories.
- Pilot in evaluate mode. Target a small set of repositories you understand, such as your platform team's own. Set
enforcementtoevaluate. - Review insights. Look at which pushes and pull requests would have failed, and why.
- Fix. Adjust the rule, the bypass list, or the shared workflow. Contact repository owners where their setup needs to change.
- Activate the pilot. Change
enforcementtoactivefor the pilot only. - Widen. Broaden the repository targeting, ideally back in evaluate mode for the new repositories. Repeat the review.
- Go organisation-wide. When insights are clean, target all intended repositories with
activeenforcement.
Step 5 has a catch. A ruleset has one enforcement status, so widening the targeting of an active ruleset enforces it on the new repositories at once. To widen safely, keep the proven ruleset active and create a second ruleset in evaluate mode for the next batch. When that batch is clean, fold it into the active ruleset and delete the evaluate one.
Evaluate mode for organisation rulesets is only available on some GitHub plans (GitHub Enterprise). If you don't see the Evaluate option in the enforcement dropdown, you can't use it. Pilot with a narrow repository list in active mode instead, and warn the pilot teams first.
A pilot ruleset
This body is the required-workflow rule from earlier chapters, scoped to repositories whose names start with pilot- and set to evaluate.
{
"name": "require-org-ci-pilot",
"target": "branch",
"enforcement": "evaluate",
"conditions": {
"ref_name": {
"include": ["~DEFAULT_BRANCH"],
"exclude": []
},
"repository_name": {
"include": ["pilot-*"],
"exclude": []
}
},
"rules": [
{
"type": "workflows",
"parameters": {
"do_not_enforce_on_create": true,
"workflows": [
{
"repository_id": 123456,
"path": ".github/workflows/org-ci.yml",
"ref": "refs/heads/main"
}
]
}
}
]
}Setting do_not_enforce_on_create to true keeps the rule from blocking the first push that creates a branch. Newly created repositories and branches then don't fail before any workflow could have run. Create the ruleset with the same call you used earlier:
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/orgs/YOUR_ORG/rulesets \
--input require-org-ci-pilot.jsonThe response includes the new ruleset's id. You need it for later updates.
What evaluate mode does and does not tell you
In evaluate mode GitHub runs the rules against real activity and records the outcome, but it never blocks anything. A push that would have failed an active rule still succeeds. The failure shows up in insights.
Keep these limits in mind:
- Evaluate mode shows what the rules would do to activity that happens during the pilot. If a team never pushes to the default branch in that window, you learn nothing about that team.
- A required workflow reports a result only after the workflow has run. Judge it over enough days to cover typical pull request traffic, including slow-moving repositories.
- Evaluation tells you nothing about how people react. Active enforcement still needs an announcement.
Reading rule insights
Rule insights are the log of rule evaluations. As an organisation owner, open Settings, then Rules, then Insights. Repository admins can see the same view for their own repository under Settings, Rules, Insights.
Each entry is a rule suite: all the rules that were evaluated for one push or one pull request merge. It records the repository, the ref, the actor, the commit range, the time and the result. You can filter the list by:
- time period
- repository
- branch or tag
- actor
- result
Open an entry to see each ruleset and each rule inside it, and which ones passed or failed. The results mean:
| Result | Meaning |
|---|---|
| Pass | All applicable rules were satisfied. |
| Fail | At least one rule was not satisfied. For an active ruleset the push was blocked. For an evaluate ruleset it would have been blocked. |
| Bypass | A rule was not satisfied, but an actor on the bypass list was allowed through. |
During a pilot, work through these questions in order:
- Which repositories fail most often? A cluster in one repository often points to a repository-specific setup problem, such as a different default branch name or a missing workflow permission.
- Which actors fail? Failures from a bot account mean you need either a bypass entry or a change to how the bot works. Prefer fixing the bot to use pull requests if that is practical.
- Which rule inside the suite failed? A required workflow failure and a missing review are different problems with different owners.
- Who bypassed, and how often? Bypass entries show whether your emergency-access design matches real behaviour. Regular bypasses by one person usually mean a missing process, not an emergency.
Querying insights with the API
The web view is good for investigation. For a rollout report you can query the same data. The organisation rule suites endpoint accepts filters such as time_period (hour, day, week, month), rule_suite_result (pass, fail, bypass, all), repository_name, ref and actor_name.
This command counts the failures of the last week by repository, most frequent first:
gh api --paginate \
"/orgs/YOUR_ORG/rulesets/rule-suites?time_period=week&rule_suite_result=fail&per_page=100" \
--jq '.[].repository_name' \
| sort | uniq -c | sort -rnTo see one suite in detail, take its id from the list and request it:
gh api /orgs/YOUR_ORG/rulesets/rule-suites/RULE_SUITE_IDThe detail response lists the evaluated rules, the ruleset each came from, and the result of each. This is the same information as the Insights detail page.
Each list entry has two result fields. result is what actually happened to the push. evaluation_result is what the rules concluded. For an evaluate ruleset the two can differ, because the push succeeds while the evaluation says fail. When you build a pilot report from evaluate-mode data, filter on the evaluation outcome, not on whether the push went through.
Changing the enforcement status
When the review is clean, update only the enforcement field:
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
/orgs/YOUR_ORG/rulesets/RULESET_ID \
-f enforcement=activeTo stop quickly during an incident, run the same command with -f enforcement=disabled. A disabled ruleset keeps its configuration and is easy to switch back on. Prefer this to deleting the ruleset, because deleting loses the configuration and the history of who changed what.
After you activate a ruleset, keep watching insights for the first few days. Failures that were rare during the pilot often appear when release time or a quarterly deadline raises the volume of merges.
Common mistakes
- Treating a quiet pilot as proof. Check that the pilot repositories had enough activity to exercise each rule.
- Widening and activating in one step. Use a separate evaluate ruleset for each new batch.
- Ignoring bypass entries. Bypass is allowed by design, but the log is your audit trail. Review it on a schedule.
- Overlapping rulesets. If another ruleset or a classic branch protection rule also applies, the effective result is the combination of all of them. A failure may come from a ruleset you did not just create. The detail view names the ruleset that produced each result.
- No announcement. Insights tell you what happened. They don't tell developers why their merge is blocked, so send the rule's purpose and a contact point first.
Exercise
Your organisation ruleset is active on 40 repositories and works well. You want to extend it to 60 more repositories, but you aren't sure they will pass. How do you extend it without blocking those teams, and how do you decide when to proceed?
Show answer
Leave the active ruleset as it is. Create a second ruleset with the same rules, enforcement set to evaluate, targeting only the 60 new repositories. Review rule insights (or the rule-suites API filtered by rule_suite_result=fail) over enough days to cover normal activity. Fix or exclude repositories that fail for legitimate reasons, and check the bypass entries. When the failures are resolved, add the 60 repositories to the active ruleset and disable or delete the evaluate one. If your plan has no evaluate mode, use a narrow pilot list in active mode and warn the teams first.
Exercise
In the rule-suites response, an entry from an evaluate-mode ruleset has result set to pass but evaluation_result set to fail. What does that mean?
Show answer
The push or merge went through, because evaluate mode never blocks. The rules would have rejected it if the ruleset were active. This is a would-be failure, so it counts toward your rollout report.