Skip to content

Commit eadb49c

Browse files
committed
Add backport workflow
If a label starting with "backport <branch>" is applied to an already merged PR then create a new PR against <branch> where the commits are cherry picked from the original PR using the '-x' flag to include the original git ref. Note the pull_request_target trigger comes with a security warning[1]: you should make sure that you do not check out, build, or run untrusted code from the pull request with this event. To guard against this we only run if the label is applied to an already merged PR and not a closed, but unmerged PR. [1] https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
1 parent bc32a27 commit eadb49c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.github/workflows/backport.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Backport merged pull request
2+
on:
3+
pull_request_target:
4+
types: [labeled]
5+
permissions:
6+
contents: write # so it can comment
7+
pull-requests: write # so it can create pull requests
8+
jobs:
9+
backport:
10+
name: Backport merged pull request
11+
runs-on: ubuntu-latest
12+
# For security reasons, we don't want to checkout and run arbitrary code when
13+
# using the pull_request_target trigger. So restrict this to cases where the
14+
# backport label is applied to an already merged PR.
15+
if: github.event.pull_request.merged && contains(github.event.label.name, 'backport')
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Create backport pull requests
19+
uses: korthout/backport-action@v1

0 commit comments

Comments
 (0)