|
6 | 6 |
|
7 | 7 | jobs: |
8 | 8 | backport: |
9 | | - if: > |
10 | | - github.event.action == 'labeled' && |
11 | | - github.event.pull_request.merged == true && |
12 | | - startsWith(github.event.label.name, 'backport ') |
| 9 | + if: github.event.pull_request.merged == true |
13 | 10 | runs-on: ubuntu-latest |
14 | 11 |
|
15 | 12 | permissions: |
16 | 13 | contents: write |
17 | 14 | pull-requests: write |
18 | 15 |
|
19 | 16 | steps: |
20 | | - - name: Determine target branch |
21 | | - id: vars |
22 | | - run: | |
23 | | - label="${{ github.event.label.name }}" |
24 | | - target="${label#backport }" |
25 | | - echo "target=$target" >> "$GITHUB_OUTPUT" |
| 17 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v 6.0.2 |
26 | 18 |
|
27 | | - - name: Checkout repo |
28 | | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v 6.0.2 |
| 19 | + - name: Backport |
| 20 | + uses: korthout/backport-action@4aaf0e03a94ff0a619c9a511b61aeb42adea5b02 # v4.2.0 |
29 | 21 | with: |
30 | | - fetch-depth: 0 |
31 | | - |
32 | | - - name: Configure git |
33 | | - run: | |
34 | | - git config user.name "github-actions" |
35 | | - git config user.email "github-actions@github.com" |
36 | | -
|
37 | | - - name: Cherry pick merge commit |
38 | | - env: |
39 | | - TARGET: ${{ steps.vars.outputs.target }} |
40 | | - PR: ${{ github.event.pull_request.number }} |
41 | | - run: | |
42 | | - MERGE_SHA=${{ github.event.pull_request.merge_commit_sha }} |
43 | | -
|
44 | | - BRANCH="backport/pr-${PR}-to-${TARGET}" |
45 | | -
|
46 | | - git fetch origin $TARGET |
47 | | - git checkout -b $BRANCH origin/$TARGET |
48 | | -
|
49 | | - git cherry-pick -x $MERGE_SHA |
50 | | -
|
51 | | - git push origin $BRANCH |
52 | | -
|
53 | | - - name: Create PR |
54 | | - env: |
55 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
56 | | - TARGET: ${{ steps.vars.outputs.target }} |
57 | | - PR: ${{ github.event.pull_request.number }} |
58 | | - run: | |
59 | | - BRANCH="backport/pr-${PR}-to-${TARGET}" |
60 | | -
|
61 | | - gh pr create \ |
62 | | - --base $TARGET \ |
63 | | - --head $BRANCH \ |
64 | | - --title "Backport PR #$PR to $TARGET" \ |
65 | | - --body "Automated backport of #$PR to \`$TARGET\`." |
| 22 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments