A GitHub Action to keep important branches up to date! It's especially useful if
you have a staging and a hotfix branch that both push to main and need to
be up to date with the latest changes to main at all times.
Here's a quick example workflow that triggers on every push on main that
updates a single branch called develop:
name: Merge branches
on:
push:
branches:
- main
jobs:
merge-branches:
name: Merge main into develop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test Local Action
uses: DerTimonius/merge-branches@v1
with:
token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
branches: develop
force: trueYou can also pass in multiple branches in an array (you have to use brackets and wrap them in quotes for this work properly):
name: Merge branches
on:
push:
branches:
- main
jobs:
merge-branches:
name: Merge main into develop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test Local Action
uses: DerTimonius/merge-git-branches@v1
with:
token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
branches: '[develop, hotfix]'
force: trueA Personal Access Token (PAT) is necessary for this action to run. You can learn about PATs here.
When the option checkTags is set to true, this aciton will check if the tag
is the HEAD of a protected branch. If it's not the head or if it's not the
head of the protected branch, the action fails.
| Name | Type | Description |
|---|---|---|
token |
required | GitHub Personal Access Token needed for the commit. |
branches |
required | The branches that should be updated. For example develop or "[develop, hotfix]" |
force |
default: false |
Defines if the commit should be force-pushed or not. |
checkTags |
default: false |
Enable tag checks by setting checkTags to true if you want to include tag validation in the GitHub Action workflow. |