Sub topic 8
Granting limited bypass access
This chapter assumes you can read a ruleset JSON body, know the repository roles (read, triage, write, maintain, admin), and have used pull requests on protected branches. A bypass actor is a person, team, app, or role that is allowed to skip a ruleset's rules. The goal is to give emergency access without turning the ruleset into a suggestion.
What a bypass list contains
Each ruleset has its own bypass_actors list. An entry has three fields:
| Field | Meaning |
|---|---|
| `actor_type` | The kind of actor: `RepositoryRole`, `Team`, `Integration` (a GitHub App), `OrganizationAdmin`, or `DeployKey`. |
| `actor_id` | The numeric ID of that actor. Repository role 5 is the admin role. |
| `bypass_mode` | `always` or `pull_request`. |
An empty list means nobody can bypass. That is the default, and it is the strictest setting.
Choosing a bypass mode
The mode limits how an actor may skip the rules.
alwayslets the actor skip the rules everywhere, including direct pushes to the protected branch.pull_requestlets the actor skip the rules only when they merge a pull request. Pushing straight to the branch is still blocked.
Prefer pull_request. The change still leaves a pull request, a diff, and a timeline entry. A direct push with always leaves much less context.
The ruleset body from the earlier chapters already uses this pattern:
{
"bypass_actors": [
{
"actor_id": 5,
"actor_type": "RepositoryRole",
"bypass_mode": "pull_request"
}
]
}Repository admins can merge a pull request without the required approval. They cannot force push or delete the branch, because those rules are still enforced for direct pushes.
Keeping the scope narrow
Narrow the list in three ways.
- Name a team instead of a role. A role such as admin covers everyone who holds it in every targeted repository. A small
release-managersteam covers only the people you chose. - Use an app for automation. If a release bot must push to the branch, add the bot's GitHub App as an
Integrationactor. Do not add a human role to cover the bot. - Split rulesets by sensitivity. Put rules that must never be skipped, such as
deletionandnon_fast_forward, in a ruleset with no bypass actors. Put the review rules in a second ruleset that has a bypass list.
Splitting works because of how rulesets combine. A rule that appears in several rulesets applies unless the actor can bypass every ruleset that contains it. The next chapter covers this in detail.
Common errors
- Using
alwaysby habit. It is easy to pick and rarely needed. Start withpull_requestand widen only when a real case requires it. - Granting the admin role organisation-wide. In an organisation ruleset, a role entry applies in every repository the ruleset targets. Admins of unrelated repositories gain bypass there.
- Forgetting to review the list. People change teams. Check the bypass list when you review the ruleset.
- Expecting silence. Bypasses are not hidden. You can find them in the rule insights, which a later chapter covers, so use that view to check that the access is used as intended.
Exercise
A release bot must push tags directly, and a small group of engineers must be able to merge urgent fixes without the usual approval. Which bypass entries would you add, and with which modes?
Show answer
Add the bot's GitHub App as an Integration actor with bypass_mode set to always, because it pushes directly. Add the engineers' team as a Team actor with bypass_mode set to pull_request, so they can skip the approval only when they merge a pull request. Put the deletion and non_fast_forward rules in a separate ruleset with no bypass actors, so no one can skip them.