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,30 @@ 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+ BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
28+ git pull origin "$BRANCH_NAME"
29+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
30+ TARGET_SHA="${{ github.event.pull_request.head.sha }}"
31+ else
32+ TARGET_SHA="${{ github.sha }}"
33+ fi
34+
2435 # Define a regex pattern to match commit messages for changelog updates
2536 CHANGELOG_UPDATE_PATTERN="^Merge pull request #[0-9]+ from ${{ github.repository_owner }}/doc/changelog-update-.*$"
37+ MESSAGE=$(git log --format=%B -n 1 "$TARGET_SHA")
2638
27- if [[ "${{ github.event.head_commit.message }} " =~ $CHANGELOG_UPDATE_PATTERN ]]; then
39+ if [[ "$MESSAGE " =~ $CHANGELOG_UPDATE_PATTERN ]]; then
2840 echo "This commit is not target. Skip the workflow."
2941 echo "SKIP_JOB=true" >> $GITHUB_OUTPUT
3042 else
43+ echo "This commit is target."
44+ echo "$MESSAGE"
3145 echo "SKIP_JOB=false" >> $GITHUB_OUTPUT
3246 fi
3347 - uses : release-drafter/release-drafter@v6
6882 uses : actions/checkout@v4
6983 with :
7084 fetch-depth : 0
71- ref : main
7285
7386 - name : Setup Java
7487 uses : actions/setup-java@v4
@@ -103,6 +116,7 @@ jobs:
103116 echo "No changes to commit."
104117 exit 0
105118 fi
106- git commit -am "Update Version With Release Draft - $REPLACE_VERSION"
107- git push origin main
119+ git commit -am "Update Version With Release Draft - $RELEASE_VERSION"
120+ BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
121+ git push origin $BRANCH_NAME
108122
0 commit comments