Configuration
Must be set to
"branch"
Conditions for the base branch (the branch you’re merging into)
Base branch patterns that should match (supports regex)
Base branch patterns that should not match (supports regex)
Conditions for the head branch (the branch with your changes)
Head branch patterns that should match (supports regex)
Head branch patterns that should not match (supports regex)
Basic Usage
Examples
Production Branches
Apply a rule only to PRs targeting production branches:Feature Branches
Apply a rule only to PRs from feature branches:Exclude WIP Branches
Skip a rule for PRs from work-in-progress branches:Specific Branch Combinations
Apply a rule only to PRs from feature branches to the main branch:Pattern Matching
The Branch Filter supports several pattern matching methods:- Exact match:
"main"
- Glob patterns:
"release-*"
- Regular expressions:
"/^feature\/.*$/"
(enclosed in forward slashes)
Practical Example
Different validation rules for different branch types:How It Works
The Branch Filter retrieves the base and head branch names from the GitHub event context and checks if they match the specified patterns. Ifmatch
is specified, the branch must match at least one of the patterns for the rule to be applied. If ignore
is specified, the branch must not match any of the patterns.
Best Practices
Use branch naming conventions consistently in your team
Create branch-specific rules that align with your development workflow
Consider branch protection rules alongside Rulesets
Be aware that branch names are case-sensitive in Git/GitHub