GitHub Action that merge a pull request if all conditions are valid.
pull_request
pull_request_target
A GitHub personal access token.
Strategy for merging the pull request, can be merge
, squash
or rebase
.
Default: rebase
Add a positive review on the pull request.
Default: false
Marks the pull request ready for review.
Default: false
Draft pull requests cannot be merged
A text or regular expression that must match the title of the pull request.
Default: ignored
title: automerge
title: '\[automerge]$'
title: '/\[automerge]$/'
title: '/\[automerge]$/i'
The list of required labels.
Default: ignored
labels: automerge
labels: |
automerge
bug
The list of authorized usernames for auto-merge.
Default: ignored
users: octocat
users: |
octocat
octodog
The list of authorized teams for auto-merge.
Default: ignored
pattern must match:
@<org>/<teamSlug>
teams: '@github/team-a'
teams: |
@github/team-a
@github/team-b
Returns true
if the pull request merged, false
otherwise.
Reason that the auto-merge is not enabled.
name: Auto-merge
on: pull_request
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Auto-merge
id: automerge
uses: Leadformance/auto-merge-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
mergeMethod: rebase
enableApproval: true
enableReadyForReview: true
labels: automerge
teams: '@github/team'
- if: ${{ steps.automerge.outputs.merged == 'true' }}
run: echo "Automerge has merged the pull request"
- if: ${{ steps.automerge.outputs.merged == 'false' }}
run: |
echo "Auto-merge could not merged the pull request"
echo "Reason: ${{ steps.automerge.outputs.reason }}"