Sub topic 10
Evaluate mode, active mode, and bypass actors
This chapter assumes you can create a ruleset, know what a pull request and a status check are, and have admin access to a test repository. It covers the two settings that control how a ruleset behaves: its enforcement status and its bypass list.
Enforcement statuses
Every ruleset has an enforcement value. It decides whether the rules are applied at all.
| Status | Effect |
|---|---|
| `disabled` | The ruleset is stored but does nothing. |
| `evaluate` | Rules are not enforced. GitHub records what would have been blocked. |
| `active` | Rules are enforced. |
Evaluate mode is the safe way to roll out a new rule. You create the ruleset in evaluate, let normal work continue, and read the results. Then you switch to active. This avoids the common failure of turning on a required check that nobody's pull requests can satisfy.
Rolling out with the REST API
The ruleset in the earlier example already starts in evaluate mode. To switch it on, send an update to the ruleset with a new enforcement value. First find its ID:
gh api repos/OWNER/REPO/rulesets
gh api --method PUT repos/OWNER/REPO/rulesets/RULESET_ID -f enforcement=activeThe first command lists rulesets and their IDs. The second changes only the enforcement field and leaves the rules as they were.
Bypass actors
The bypass_actors list names who may skip the rules in a ruleset. In the earlier example it was empty, so nobody could bypass. A bypass entry has an actor type, such as a repository role, a team, or an app, and a bypass mode:
always: the actor can bypass at any time, including by pushing directly.pull_request: the actor can bypass only when working through a pull request, for example merging without the required approvals.
Prefer pull_request mode where you can. It keeps a record of the change in a pull request, while always allows silent direct pushes.
This differs from classic protection. There, enforce_admins is one switch for all administrators. With a ruleset, you choose exactly which roles, teams, or apps can bypass, and administrators have no automatic exemption unless you list them.
Checking results
Rule insights, found under the repository's Rulesets settings, show each push or merge that a rule blocked or would have blocked. Look for patterns, such as a check name that never reports on some branches.
Exercise
You create a ruleset requiring the build status check. Two days later, insights show that 30% of pushes would have been blocked because the check is named ci/build on some branches. What should you do before switching to active?
Show answer
Stay in evaluate mode and fix the mismatch. Correct the required check name, or make the workflows report a consistent name, then confirm in insights that valid work would no longer be blocked. Only then change enforcement to active. Do not solve it by adding people to the bypass list.
Exercise
A release manager needs to merge urgent fixes without waiting for approvals, but you still want a pull request on record. Which bypass mode do you choose?
Show answer
pull_request. It lets the actor bypass the rules only through a pull request, so the change stays visible and reviewable. always would also allow direct pushes.