@@ -25,38 +25,48 @@ jobs:
2525
2626 - name : Get merged branch name
2727 id : get-branch
28+ env :
29+ BRANCH_NAME : ${{ github.event.pull_request.head.ref }}
30+ HEAD_REPO : ${{ github.event.pull_request.head.repo.full_name }}
2831 run : |
29- # Get the head branch name from the merged PR
30- BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
32+ # Get the head branch name and repo from the merged PR
3133 echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
32- echo "Merged branch: $BRANCH_NAME"
34+ echo "head-repo=$HEAD_REPO" >> $GITHUB_OUTPUT
35+ echo "Merged branch: $BRANCH_NAME from $HEAD_REPO"
3336
3437 - name : Check if branch exists
3538 id : check-branch
39+ env :
40+ HEAD_REF : ${{ steps.get-branch.outputs.branch-name }}
41+ HEAD_REPO : ${{ steps.get-branch.outputs.head-repo }}
3642 run : |
37- BRANCH_NAME="${{ steps.get-branch.outputs.branch-name }}"
38-
39- # Check if the branch still exists on the remote
40- if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
43+ # Check if the branch still exists on the fork remote
44+ if git ls-remote "https://github.com/${HEAD_REPO}.git" "refs/heads/${HEAD_REF}" | grep -q "refs/heads/${HEAD_REF}"; then
4145 echo "branch-exists=true" >> $GITHUB_OUTPUT
42- echo "Branch $BRANCH_NAME exists and can be used for backport"
46+ echo "Branch $HEAD_REF exists in $HEAD_REPO and can be used for backport"
4347 else
4448 echo "branch-exists=false" >> $GITHUB_OUTPUT
45- echo "Branch $BRANCH_NAME no longer exists, cannot create backport PR"
49+ echo "Branch $HEAD_REF no longer exists in $HEAD_REPO , cannot create backport PR"
4650 fi
4751
4852 - name : Create backport PR
4953 if : steps.check-branch.outputs.branch-exists == 'true'
5054 uses : actions/github-script@v7
55+ env :
56+ BRANCH_NAME : ${{ steps.get-branch.outputs.branch-name }}
57+ ORIGINAL_PR_NUMBER : ${{ github.event.pull_request.number }}
58+ ORIGINAL_PR_TITLE : ${{ github.event.pull_request.title }}
59+ ORIGINAL_PR_BODY : ${{ github.event.pull_request.body }}
60+ ORIGINAL_PR_AUTHOR : ${{ github.event.pull_request.user.login }}
5161 with :
5262 github-token : ${{ secrets.GITHUB_TOKEN }}
5363 script : |
54- const branchName = '${{ steps.get-branch.outputs.branch-name }}' ;
55- const originalPrNumber = context.payload.pull_request.number ;
56- const originalPrTitle = context.payload.pull_request.title ;
57- const originalPrBody = context.payload.pull_request.body || '';
58- const originalPrAuthor = context.payload.pull_request.user.login ;
59-
64+ const branchName = process.env.BRANCH_NAME ;
65+ const originalPrNumber = process.env.ORIGINAL_PR_NUMBER ;
66+ const originalPrTitle = process.env.ORIGINAL_PR_TITLE ;
67+ const originalPrBody = process.env.ORIGINAL_PR_BODY || '';
68+ const originalPrAuthor = process.env.ORIGINAL_PR_AUTHOR ;
69+
6070 // Create the backport PR
6171 try {
6272 const response = await github.rest.pulls.create({
0 commit comments