1313
1414jobs :
1515 create_draft_pr :
16- name : Create a draft PR for release/hotfix
16+ name : Create draft PR
1717 runs-on : ubuntu-latest
1818 permissions :
1919 contents : write
2020 # only create draft pull requests on pushing to branches 'release/' or 'hotfix/'
21- if : (startsWith(github.head_ref , 'release/') || startsWith(github.head_ref , 'hotfix/'))
21+ if : (startsWith(github.ref_name , 'release/') || startsWith(github.ref_name , 'hotfix/'))
2222
2323 steps :
2424 - name : Set GitHub token
@@ -28,23 +28,23 @@ jobs:
2828 - name : Checkout repository
2929 uses : actions/checkout@v3
3030 with :
31- ref : ${{ github.head_ref }}
31+ ref : ${{ github.ref_name }}
3232 token : ${{ env.GH_TOKEN }}
3333 # needed by "gh pr create"
3434 fetch-depth : 0
3535
3636 - name : Set environment variables for publishing release
37- if : startsWith(github.head_ref , 'release/')
37+ if : startsWith(github.ref_name , 'release/')
3838 run : |
39- BRANCH_NAME="${{ github.head_ref }}"
39+ BRANCH_NAME="${{ github.ref_name }}"
4040 VERSION=${BRANCH_NAME#release/}
4141 echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
4242 echo "RELEASE_TYPE=release" >> $GITHUB_ENV
4343
4444 - name : Set environment variables for publishing hotfix
45- if : startsWith(github.head_ref , 'hotfix/')
45+ if : startsWith(github.ref_name , 'hotfix/')
4646 run : |
47- BRANCH_NAME="${{ github.head_ref }}"
47+ BRANCH_NAME="${{ github.ref_name }}"
4848 VERSION=${BRANCH_NAME#hotfix/}
4949 echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
5050 echo "RELEASE_TYPE=hotfix" >> $GITHUB_ENV
@@ -62,20 +62,15 @@ jobs:
6262 echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV
6363
6464 - name : Create PR '${{ env.PR_TITLE }}'
65- env :
66- PR_LABELS : " automated-pr,${{ env.RELEASE_TYPE}}-pr"
6765 run : |
68- LABELS=${{ env.PR_LABELS }}
69- for LABEL in $(echo $LABELS | sed "s/,/ /g"); do gh label create $LABEL --force; done
66+ PR_LABELS="automated-pr,${RELEASE_TYPE}-pr"
67+ for LABEL in $(echo $PR_LABELS | sed "s/,/ /g"); do gh label create $LABEL --force; done
7068 [[ ${PRE_RELEASE:false} == "true" ]] && gh label create 'pre-release' --force
7169
72- PR_BODY=$(git log ${{ env.BRANCH_MAIN }}..${{ github.head_ref }} --pretty=format:%s)
73-
7470 gh pr create \
7571 --draft \
7672 --base ${{ env.BRANCH_MAIN }} \
77- --head ${{ github.head_ref }} \
73+ --head ${{ github.ref_name }} \
7874 --title "${{ env.PR_TITLE }}" \
79- --body "$PR_BODY" \
8075 --label "${{ env.PR_LABELS }}" \
8176 --fill
0 commit comments