Merge Action
Automatically merge pull requests
The Merge Action allows you to automatically merge pull requests when they pass all validations. This is useful for automating routine merges, reducing manual work, and maintaining a consistent workflow.
Configuration
Merge method to use: “merge”, “squash”, or “rebase”
Custom title for the merge commit (supports templates)
Custom message for the merge commit (supports templates)
Basic Usage
Examples
Simple Auto-Merge
Automatically merge PRs that pass all validations:
Custom Commit Messages
Specify custom titles and messages for merge commits:
Conditional Auto-Merge
Merge documentation PRs automatically after review:
Merge Methods
Creates a merge commit that preserves all commit history from the PR branch.
Best for: Preserving detailed history and context of changes.
Creates a merge commit that preserves all commit history from the PR branch.
Best for: Preserving detailed history and context of changes.
Combines all PR commits into a single commit on the base branch.
Best for: Keeping a clean, linear history on the main branch.
Applies each commit from the PR branch individually onto the base branch.
Best for: Maintaining a linear history while preserving individual commits.
How It Works
Check Mergeability
The action first checks if the PR is mergeable
Process Templates
If custom commit titles or messages are provided, it processes the templates
Perform Merge
The action merges the PR using the specified method
Error Handling
The Merge Action will fail under these conditions:
- PR has merge conflicts
- PR doesn’t meet branch protection requirements
- Required status checks are failing
- User lacks permission to merge
When merge fails, the error will be logged but won’t affect other actions.
Use Cases
Auto-Merge Dependency Updates
Automatically merge dependency updates that pass tests:
Auto-Merge Typo Fixes
Automatically merge simple typo fixes after approval:
Auto-Merge for Specific Labels
Merge PRs with specific labels after CI success:
Best Practices
Be cautious with auto-merge on critical branches - always include sufficient validation
Security Considerations
- Only enable auto-merge for trusted contributors or with strict validation
- Ensure all required checks (tests, approvals) are passing before merge
- Consider limiting auto-merge to non-critical repositories or branches
- Maintain audit logs of auto-merged PRs