Skip to content

Commit ca64726

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

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

.github/workflows/release-drafter.yml

Lines changed: 14 additions & 7 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
@@ -23,11 +23,19 @@ jobs:
2323
run: |
2424
# Define a regex pattern to match commit messages for changelog updates
2525
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
26+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
27+
TARGET_SHA="${{ github.event.pull_request.head.sha }}"
28+
else
29+
TARGET_SHA="${{ github.sha }}"
30+
fi
31+
MESSAGE=$(git log --format=%B -n 1 "$TARGET_SHA")
32+
33+
if [[ "$MESSAGE" =~ $CHANGELOG_UPDATE_PATTERN ]]; then
2834
echo "This commit is not target. Skip the workflow."
2935
echo "SKIP_JOB=true" >> $GITHUB_OUTPUT
3036
else
37+
echo "This commit is target."
38+
echo "$MESSAGE"
3139
echo "SKIP_JOB=false" >> $GITHUB_OUTPUT
3240
fi
3341
- uses: release-drafter/release-drafter@v6
@@ -68,7 +76,6 @@ jobs:
6876
uses: actions/checkout@v4
6977
with:
7078
fetch-depth: 0
71-
ref: main
7279

7380
- name: Setup Java
7481
uses: actions/setup-java@v4
@@ -103,6 +110,6 @@ jobs:
103110
echo "No changes to commit."
104111
exit 0
105112
fi
106-
git commit -am "Update Version With Release Draft - $REPLACE_VERSION"
107-
git push origin main
108-
113+
git commit -am "Update Version With Release Draft - $RELEASE_VERSION"
114+
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
115+
git push origin $BRANCH_NAME

0 commit comments

Comments
 (0)