Skip to content

Instantly share code, notes, and snippets.

@benhatsor
Last active June 1, 2026 13:56
Show Gist options
  • Select an option

  • Save benhatsor/6116ca83d4ff4947caeb011c59a5bccf to your computer and use it in GitHub Desktop.

Select an option

Save benhatsor/6116ca83d4ff4947caeb011c59a5bccf to your computer and use it in GitHub Desktop.
PRs and CI branch ruleset. To use in your repository, go to Settings > Rules > Rulesets > New ruleset > Import a ruleset > Select this file (without the jsonc comments).
{
"name": "PRs and CI",
"target": "branch",
"source_type": "Repository",
"enforcement": "active",
// Target specified branches
"conditions": {
"ref_name": {
"include": [
// Default branch (usually 'main')
"~DEFAULT_BRANCH"
]
}
},
// Allow specified actors to bypass ruleset
"bypass_actors": [
{
"actor_type": "RepositoryRole",
// Repository admin role ID
"actor_id": 5,
"bypass_mode": "always"
}
],
"rules": [
{
// Require a PR to push
"type": "pull_request"
},
{
// Require specified status checks to pass
"type": "required_status_checks",
"parameters": {
"required_status_checks": [
{
// Job name (inside the workflow)
"context": "test",
// ID for all GitHub Actions
"integration_id": 15368
}
]
}
},
// Default ruleset settings
{
// Prevent branch deletion
"type": "deletion"
},
{
// Prevent force pushing
"type": "non_fast_forward"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment