44 push :
55 branches :
66 - main
7+ pull_request :
78 workflow_dispatch :
89
910jobs :
1011 update_release_draft :
11- if : ${{ !contains(github.head_ref, 'doc/changelog-update-') && startsWith(github.event.head_commit.message, 'Merge pull request') }}
1212 permissions :
1313 contents : write
1414 pull-requests : write
@@ -18,16 +18,28 @@ jobs:
1818 skip_job : ${{ steps.check.outputs.SKIP_JOB }}
1919
2020 steps :
21+ - name : Fetch Sources
22+ uses : actions/checkout@v4
23+
2124 - name : Check Commit Message
2225 id : check
2326 run : |
27+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
28+ TARGET_SHA="${{ github.event.pull_request.head.sha }}"
29+ else
30+ TARGET_SHA="${{ github.sha }}"
31+ fi
32+
2433 # Define a regex pattern to match commit messages for changelog updates
2534 CHANGELOG_UPDATE_PATTERN="^Merge pull request #[0-9]+ from ${{ github.repository_owner }}/doc/changelog-update-.*$"
35+ MESSAGE=$(git log --format=%B -n 1 "$TARGET_SHA")
2636
27- if [[ "${{ github.event.head_commit.message }} " =~ $CHANGELOG_UPDATE_PATTERN ]]; then
37+ if [[ "$MESSAGE " =~ $CHANGELOG_UPDATE_PATTERN ]]; then
2838 echo "This commit is not target. Skip the workflow."
2939 echo "SKIP_JOB=true" >> $GITHUB_OUTPUT
3040 else
41+ echo "This commit is target."
42+ echo "$MESSAGE"
3143 echo "SKIP_JOB=false" >> $GITHUB_OUTPUT
3244 fi
3345 - uses : release-drafter/release-drafter@v6
6880 uses : actions/checkout@v4
6981 with :
7082 fetch-depth : 0
71- ref : main
7283
7384 - name : Setup Java
7485 uses : actions/setup-java@v4
@@ -103,6 +114,7 @@ jobs:
103114 echo "No changes to commit."
104115 exit 0
105116 fi
106- git commit -am "Update Version With Release Draft - $REPLACE_VERSION"
107- git push origin main
117+ git commit -am "Update Version With Release Draft - $RELEASE_VERSION"
118+ BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
119+ git push origin $BRANCH_NAME
108120
0 commit comments