Automatically set auto-merge
on pull requests programmatically using
GitHub Action Expressions.
If you are working on a project independently and you wish to use the same development workflow you are familiar with when working with other individuals, you may want this action.
You can set this action to auto-merge dependabot or other bot-generated pull requests.
- Enable auto-merge
- Create a branch protection rule
- Create a required status check
- At least one required check must be added to fully enable GitHub's auto-merge feature. (this action can be your required check)
- Add
.github/workflows/auto-merge.yaml
to your repository.
name: Enable Auto Merge
on:
pull_request_target:
branches:
- main
jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- uses: kenhowardpdx/auto-merge-action@v1
if: ${{ github.actor == 'dependabot[bot]' }}
NOTE: The auto-generated $GITHUB_TOKEN
will not work in most cases if you
expect workflows to be triggered once the merge occurs. It's preferred you
generate a personal access token and add it to
your repository secrets. In addition, if you enable
auto-merge for dependabot, you will need to add the same secret key (preferably
a different value) to dependabot secrets.
merge_method
: MERGE, SQUASH, or REBASE. Default: MERGE. PullRequestMergeMethodtoken
: A token with repo privileges. Default: $GITHUB_TOKEN.
While the action works on both pull_request
and pull_request_target
, you may
want to use pull_request_target
which allows this action to be triggered by
pull requests from forks.