Skip to content

Commit d367778

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

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

.github/workflows/release-drafter.yml

Lines changed: 18 additions & 5 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
@@ -18,16 +18,29 @@ 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+
git pull
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+
2434
# Define a regex pattern to match commit messages for changelog updates
2535
CHANGELOG_UPDATE_PATTERN="^Merge pull request #[0-9]+ from ${{ github.repository_owner }}/doc/changelog-update-.*$"
36+
MESSAGE=$(git log --format=%B -n 1 "$TARGET_SHA")
2637
27-
if [[ "${{ github.event.head_commit.message }}" =~ $CHANGELOG_UPDATE_PATTERN ]]; then
38+
if [[ "$MESSAGE" =~ $CHANGELOG_UPDATE_PATTERN ]]; then
2839
echo "This commit is not target. Skip the workflow."
2940
echo "SKIP_JOB=true" >> $GITHUB_OUTPUT
3041
else
42+
echo "This commit is target."
43+
echo "$MESSAGE"
3144
echo "SKIP_JOB=false" >> $GITHUB_OUTPUT
3245
fi
3346
- uses: release-drafter/release-drafter@v6
@@ -68,7 +81,6 @@ jobs:
6881
uses: actions/checkout@v4
6982
with:
7083
fetch-depth: 0
71-
ref: main
7284

7385
- name: Setup Java
7486
uses: actions/setup-java@v4
@@ -103,6 +115,7 @@ jobs:
103115
echo "No changes to commit."
104116
exit 0
105117
fi
106-
git commit -am "Update Version With Release Draft - $REPLACE_VERSION"
107-
git push origin main
118+
git commit -am "Update Version With Release Draft - $RELEASE_VERSION"
119+
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
120+
git push origin $BRANCH_NAME
108121

0 commit comments

Comments
 (0)