Conditions
Filter when rules are applied
Conditions (the if
property) determine whether a rule should be applied based on various criteria. They allow you to target specific pull requests based on authors, branches, files, labels, and more.
Condition Structure
Conditions are defined in the if
array of a rule:
All conditions must pass for the rule to be applied. Each condition has a type
and type-specific parameters.
Available Condition Types
Author
Filter based on the PR author
Branch
Filter based on branch names
Description
Filter based on PR description content
Files
Filter based on changed files
Label
Filter based on PR labels
Milestone
Filter based on PR milestone
Repository
Filter based on repository properties
Team
Filter based on team membership
Usage Examples
Filter by Author
Only apply a rule to PRs from specific users:
Filter by Branch
Only apply a rule to PRs targeting a specific branch:
Filter by Files Changed
Only apply a rule when specific files are modified:
Filter by Label
Only apply a rule to PRs with specific labels:
Multiple Conditions
All conditions must pass for the rule to be applied:
This rule will only apply to PRs:
- Targeting the
main
branch, AND - Labeled with
security
, AND - Not created by
dependabot
Pattern Matching
Most conditions support pattern matching, which can be:
- Exact match:
"main"
- Glob pattern:
"feat/*"
- Regular expression:
"/^feat\/.+$/"
When using regular expressions, enclose the pattern in forward slashes (/pattern/
).
Complete Example
This rule only applies to PRs that:
- Modify frontend JavaScript/TypeScript files
- Target the
main
branch - Are not created by Dependabot