GitHub action to automate branch merging
on:
push:
branches:
- "*"
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: emiliopedrollo/auto-merge@v1.2.0
with:
github_token: ${{ github.token }}
target_branch: 'master'
on:
pull_request:
branches: [ master ]
types: [ opened, synchronize, reopened ]
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: emiliopedrollo/auto-merge@v1.2.0
with:
github_token: ${{ github.token }}
target_branch: ${{ github.sha }}
source_ref: 'master'
Note: Use with caution, if there's another workflow that also modifies or update the repo some evil loop may occur.
on:
push:
branches:
- "*"
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: emiliopedrollo/auto-merge@v1.2.0
with:
github_token: ${{ github.token }}
target_branch: 'master'
commit_message: 'Branch {target_branch} auto-merged {source_ref}'
Required - A valid GitHub Token used to perform the merge. This can be the Token provided by GitHub Workflows, or a custom token set at a workflow secret.
The token provided by the Workflow is conveniently available as a context var: ${{ gihutb.token }}
.
Optional - The head to merge. This can be a branch name or a commit SHA1. If none is provided the SHA1 hash of the commit that triggered the workflow will be used.
Required - The name of the base branch that the head will be merged into.
Optional - A custom commit message to the merge commit. You can place a (very limited) set of variables in the message enclosed in curly braces ({}
).
The available vars are:
source_ref
: The head of the merge (i.e. the branch name or commit SHA1 from the source)target_branch
: The base The branch name (i.e. The branch name of the destination)
Optional - Either or not allow fast-forward. Default: true
.
Optional - If enabled it can allow for commits being removed from the target branch, use with caution. Default: false