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
@@ -20,14 +20,24 @@ jobs:
2020 steps :
2121 - name : Check Commit Message
2222 id : check
23+ with :
24+ ref : ${{ github.event.pull_request.head.ref }}
2325 run : |
2426 # Define a regex pattern to match commit messages for changelog updates
2527 CHANGELOG_UPDATE_PATTERN="^Merge pull request #[0-9]+ from ${{ github.repository_owner }}/doc/changelog-update-.*$"
26-
27- if [[ "${{ github.event.head_commit.message }}" =~ $CHANGELOG_UPDATE_PATTERN ]]; then
28+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
29+ TARGET_SHA="${{ github.event.pull_request.head.sha }}"
30+ else
31+ TARGET_SHA="${{ github.sha }}"
32+ fi
33+ MESSAGE=$(git log --format=%B -n 1 "$TARGET_SHA")
34+
35+ if [[ "$MESSAGE" =~ $CHANGELOG_UPDATE_PATTERN ]]; then
2836 echo "This commit is not target. Skip the workflow."
2937 echo "SKIP_JOB=true" >> $GITHUB_OUTPUT
3038 else
39+ echo "This commit is target."
40+ echo "$MESSAGE"
3141 echo "SKIP_JOB=false" >> $GITHUB_OUTPUT
3242 fi
3343 - uses : release-drafter/release-drafter@v6
6878 uses : actions/checkout@v4
6979 with :
7080 fetch-depth : 0
71- ref : main
7281
7382 - name : Setup Java
7483 uses : actions/setup-java@v4
@@ -103,6 +112,6 @@ jobs:
103112 echo "No changes to commit."
104113 exit 0
105114 fi
106- git commit -am "Update Version With Release Draft - $REPLACE_VERSION "
107- git push origin main
108-
115+ git commit -am "Update Version With Release Draft - $RELEASE_VERSION "
116+ BRANCH_NAME=$( git rev-parse --abbrev-ref HEAD)
117+ git push origin $BRANCH_NAME
0 commit comments