blob: f34f8b04d420c9ccaadeb355a98e4a5a8b05ecdc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
name: Backport PR on Label
on:
pull_request_target:
types:
- closed
- labeled
jobs:
backport:
name: Create Backport PR
runs-on: ubuntu-latest
# Only backport, when an MR is just merged that has the correct labels
# OR when an already merged MR gets the label for backporting added
if: >
(
github.event.action == 'closed' &&
github.event.pull_request.merged == true &&
contains(join(github.event.pull_request.labels.*.name, ','), 'backport: ')
) ||
(
github.event.action == 'labeled' &&
github.event.pull_request.merged == true &&
startsWith(github.event.label.name, 'backport: ')
)
# Required permissions for backporting
permissions:
contents: write
pull-requests: write
steps:
# The backport requires a full git repo to actually work.
# This provides it
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
# As we don't actually execute untrusted code for creating the MR this is fine
allow-unsafe-pr-checkout: true
- name: Create backport PRs
id: backport
uses: korthout/backport-action@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Copy all labels that don't start with `backport: `
copy_labels_pattern: '^(?!backport: ).*$'
# Only backport if there is a label that begins with `backport: `
label_pattern: '^backport: (.*)$'
pull_description: |-
Automated backport of #${pull_number} to `${target_branch}`, triggered by a label.
branch_name: backport/${pull-number}/${target_branch}
|