Skip to content

A GitHub Action to automatically merge Pull Requests when all checks pass.

License

Notifications You must be signed in to change notification settings

kenhowardpdx/auto-merge-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

auto-merge-action status

Auto Merge Action

Automatically set auto-merge on pull requests programmatically using GitHub Action Expressions.

Benefits

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.

Usage

  1. Enable auto-merge
  2. Create a branch protection rule
  3. 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)
  4. Add .github/workflows/auto-merge.yaml to your repository.

Example Workflow

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.

Inputs

  • merge_method: MERGE, SQUASH, or REBASE. Default: MERGE. PullRequestMergeMethod
  • token: A token with repo privileges. Default: $GITHUB_TOKEN.

GitHub Events

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.

About

A GitHub Action to automatically merge Pull Requests when all checks pass.

Resources

License

Stars

Watchers

Forks

Packages

No packages published