Skip to content

Use Mergiraf when backporting PRs #9815

Use Mergiraf when backporting PRs

Use Mergiraf when backporting PRs #9815

Workflow file for this run

name: Backport
on:
pull_request_target:
types: [closed, labeled]
branches: [main, release-*]
# WARNING:
# When extending this action, be aware that $GITHUB_TOKEN allows write access to
# the GitHub repository. This means that it should not evaluate user input in a
# way that allows code injection.
jobs:
backport:
name: Backport Pull Request
# Run the action if a PR is merged with backport labels
# OR
# when already merged PR is labeled with backport labels
if: >
github.event.pull_request.merged
&& (
github.event.action == 'closed'
|| (
github.event.action == 'labeled'
&& startsWith(github.event.label.name, 'backport/')
)
)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
# required to find all branches
fetch-depth: 0
token: ${{ secrets.GH_BACKPORT_TOKEN }}
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Mergiraf
env:
MERGIRAF_VERSION: v0.10.0 # renovate: datasource=gitea-releases registryUrl=https://codeberg.org depName=mergiraf/mergiraf
run: |
mkdir .git/mergiraf
curl --proto '=https' --tlsv1.2 --retry 5 --retry-all-errors -sSLfo .git/mergiraf/mergiraf.tar.gz "https://codeberg.org/mergiraf/mergiraf/releases/download/$MERGIRAF_VERSION/mergiraf_x86_64-unknown-linux-musl.tar.gz"
tar xvf .git/mergiraf/mergiraf.tar.gz -C .git/mergiraf
.git/mergiraf/mergiraf --version
.git/mergiraf/mergiraf languages --gitattributes >.git/info/attributes
git config merge.conflictStyle diff3
git config merge.mergiraf.name mergiraf
git config merge.mergiraf.driver '${{ github.workspace }}/.git/mergiraf/mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P -l %L'
- name: Create backport PRs
uses: korthout/backport-action@v3.2.0
with:
# Inputs documented here: https://github.com/korthout/backport-action?tab=readme-ov-file#inputs
github_token: ${{ secrets.GH_BACKPORT_TOKEN }}
github_workspace: ${{ github.workspace }}
# Regex pattern to match github labels
# The capture group catches the target branch
# i.e. label backport/release-1.23 will create backport PR for branch release-1.23
label_pattern: ^backport\/([^ ]+)$
pull_description: |-
Automated backport to `${target_branch}`, triggered by a label in #${pull_number}.
See ${issue_refs}.