Skip to content

Commit 710fd7c

Browse files
committed
Add pull request trigger to release drafter workflow
1 parent 6db946f commit 710fd7c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/release-drafter.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on:
44
push:
55
branches:
66
- main
7+
pull_request:
78
workflow_dispatch:
89

910
jobs:
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,19 @@ 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-.*$"
28+
MESSAGE=$(git log --format=%B -n 1 ${{ github.event.pull_request.head.sha }})
2629
27-
if [[ "${{ github.event.head_commit.message }}" =~ $CHANGELOG_UPDATE_PATTERN ]]; then
30+
if [[ "MESSAGE" =~ $CHANGELOG_UPDATE_PATTERN ]]; then
2831
echo "This commit is not target. Skip the workflow."
2932
echo "SKIP_JOB=true" >> $GITHUB_OUTPUT
3033
else
34+
echo "This commit is target."
35+
echo "$MESSAGE"
3136
echo "SKIP_JOB=false" >> $GITHUB_OUTPUT
3237
fi
3338
- uses: release-drafter/release-drafter@v6
@@ -104,5 +109,6 @@ jobs:
104109
exit 0
105110
fi
106111
git commit -am "Update Version With Release Draft - $REPLACE_VERSION"
107-
git push origin main
112+
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
113+
git push origin $BRANCH_NAME
108114

0 commit comments

Comments
 (0)