File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 88jobs :
99 backport :
1010 runs-on : ubuntu-latest
11+
1112 steps :
1213 - name : Checkout repository
1314 uses : actions/checkout@v3
1718 env :
1819 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
1920 run : |
20- PR_NUMBER=$(gh pr list --state merged --base main --json number --jq '.[0].number')
21+ # Get the latest commit hash on main
22+ COMMIT_HASH=$(git rev-parse HEAD)
23+ echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
24+
25+ # Find the pull request associated with the commit
26+ PR_NUMBER=$(gh pr list --state merged --base main --json number,mergeCommit --jq ".[] | select(.mergeCommit == \"$COMMIT_HASH\").number")
2127 echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
28+
29+ # Fetch the labels for the PR
2230 LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name')
2331 echo "LABELS=$LABELS" >> $GITHUB_ENV
2432
5058 git checkout $TARGET_BRANCH
5159 git checkout -b $BACKPORT_BRANCH
5260
53- # Cherry-pick all commits from the PR
54- COMMITS=$(gh pr view ${{ env.PR_NUMBER }} --json commits --jq '.commits[].oid')
55- for COMMIT in $COMMITS; do
56- git cherry-pick $COMMIT || (git cherry-pick --abort && exit 1)
57- done
61+ # Cherry-pick the merge commit
62+ git cherry-pick ${{ env.COMMIT_HASH }} || (git cherry-pick --abort && exit 1)
5863
5964 # Push the new branch
6065 git push origin $BACKPORT_BRANCH
You can’t perform that action at this time.
0 commit comments