Configuration
Must be set to
"approvals"
Requirements for the number of approvals
Minimum number of approvals required
Maximum number of approvals allowed
Specific users who must approve the PR
Whether code owners must approve changes to their files
Custom message to display when validation fails
Basic Usage
Examples
Minimum Approvals
Require a minimum number of approvals:Required Approvers
Require approval from specific users:Code Owners Approval
Require approval from code owners:Combined Requirements
Combine multiple approval requirements:How It Works
1
Get Reviews
The validator retrieves all reviews for the PR
2
Filter Approvals
It filters to find the latest review from each user, keeping only approvals
3
Check Count
If
count
is specified, it verifies the number of approvals meets requirements4
Check Required Approvers
If
include
is specified, it checks if all required users have approved5
Check Code Owners
If
require_code_owners
is true, it checks if code owners have approved changes to their files6
Return Result
Returns a validation result with status (pass, fail, or error) and a message
Code Owners Integration
The validator can check for approval from code owners as defined in a CODEOWNERS file. To use this feature:-
Create a file at
.github/CODEOWNERS
in your repository -
Define ownership patterns, for example:
-
Enable the
require_code_owners
option in your validation rule
Practical Use Cases
Basic Approval Workflow
Implement a simple approval workflow:Different Requirements by Branch
Apply stricter requirements for important branches:Security Review for Sensitive Changes
Require security team approval for security-related changes:Auto-Merge When Approved
Automatically merge PRs when they receive sufficient approvals:Best Practices
Set approval requirements appropriate to your team size
Use code owners for specialized areas of your codebase
Consider different requirements for different branches
Provide clear feedback about what approvals are still needed
Be mindful of approval requirements for teams with limited resources
Benefits of Approval Validation
- Enforced Code Review: Ensures code is properly reviewed before merging
- Knowledge Sharing: Encourages knowledge sharing across the team
- Quality Control: Maintains code quality through peer review
- Compliance: Helps meet regulatory or organizational requirements for code review
- Specialized Review: Ensures appropriate experts review relevant changes