File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : backport
2
+
3
+ on :
4
+ pull_request :
5
+ types : [labeled]
6
+
7
+ # Set permissions at the job level.
8
+ permissions : {}
9
+
10
+ jobs :
11
+ backport :
12
+ if : ${{ startsWith(github.event.label.name, 'backport ') }}
13
+ runs-on : ubuntu-latest
14
+ permissions :
15
+ contents : write
16
+ pull-requests : write
17
+
18
+ steps :
19
+ - uses : actions/checkout@v2
20
+ with :
21
+ fetch-depth : 0
22
+ persist-credentials : true
23
+
24
+ - name : Create backport PR
25
+ run : |
26
+ set -eux
27
+
28
+ git config --global user.name "pytest bot"
29
+ git config --global user.email "[email protected] "
30
+
31
+ label='${{ github.event.label.name }}'
32
+ target_branch="${label#backport }"
33
+ backport_branch=backport-${{ github.event.number }}-to-"${target_branch}"
34
+ subject="[$target_branch] $(gh pr view --json title -q .title ${{ github.event.number }})"
35
+
36
+ git checkout origin/"${target_branch}" -b "${backport_branch}"
37
+ git cherry-pick -x --mainline 1 ${{ github.event.pull_request.merge_commit_sha }}
38
+ git commit --amend --message "$subject"
39
+ git push --set-upstream origin --force-with-lease "${backport_branch}"
40
+ gh pr create \
41
+ --base "${target_branch}" \
42
+ --title "${subject}" \
43
+ --body "Backport of PR #${{ github.event.number }} to $target_branch branch. PR created by backport workflow."
44
+ env :
45
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change @@ -391,6 +391,13 @@ actual latest release). The procedure for this is:
391
391
request, as described above. An exception to this is if the bug fix is not
392
392
applicable to ``main `` anymore.
393
393
394
+ Automatic method:
395
+
396
+ Add a ``backport 1.2.x `` label to the PR you want to backport. This will create
397
+ a backport PR against the ``1.2.x `` branch.
398
+
399
+ Manual method:
400
+
394
401
#. ``git checkout origin/1.2.x -b backport-XXXX `` # use the main PR number here
395
402
396
403
#. Locate the merge commit on the PR, in the *merged * message, for example:
You can’t perform that action at this time.
0 commit comments