Merge all PRs with the specified label into a branch.
See action.yml
input | description | required | default |
---|---|---|---|
token | GitHub token. | true | |
base | The name of the base branch. Merge operations will be performed on the basis of this branch. | true | |
target | The name of the target branch. This branch will be checked out from the base branch and accept all merges. | true | |
label-name | The name of a label to find PRs to merge. | true | |
The email of the committer. | false | merge-branches-bot@github.com | |
name | The name of the committer. | false | merge-branches-bot |
name: 'merge-branches'
on:
workflow_dispatch:
inputs:
base:
description: 'The name of the base branch. Merge operations will be performed on the basis of this branch.'
required: true
default: 'main'
type: string
target:
description: 'The name of the target branch. This branch will be checked out from the base branch and accept all merges.'
required: true
type: string
label-name:
description: 'The name of a label to find PRs to merge.'
required: true
type: string
permissions: write-all
jobs:
merge-branches:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: codytseng/merge-branches-github-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: ${{ inputs.base }}
target: ${{ inputs.target }}
label-name: ${{ inputs.label-name }}
- Get all open PRs.
- Find PRs containing the specified label.
git config --global user.email ${email}
git config --global user.name ${name}
git fetch origin
git checkout ${base}
git pull origin ${base}
git branch ${target} -D
git checkout -b ${target}
- Loop branches
git merge origin/${branchName}
(Abort the merge if an error occurs.) git push origin ${target} -f