Skip to content

Commit 93ba08a

Browse files
ShahanaFarooquirustyrussell
authored andcommitted
github: Check if change entry is logged in PR description
1 parent 9b46990 commit 93ba08a

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,27 @@ jobs:
4444
4545
- name: Check changelog
4646
run: |
47-
base_ref="${{ github.base_ref }}"
48-
if [ -z "$base_ref" ]; then
49-
base_ref="master"
47+
EVENT_NAME="${{ github.event_name }}"
48+
BASE_REF="${{ github.base_ref }}"
49+
if [ -z "$BASE_REF" ]; then
50+
BASE_REF="master"
5051
fi
51-
if [[ -z "$(git log origin/$base_ref..HEAD --oneline --grep='Changelog-')" && "$(git rev-parse --abbrev-ref HEAD)" != "$base_ref" ]]; then
52-
echo "::error::'Changelog' entry is missing in all commits" && exit 1
52+
echo "Event Name: $EVENT_NAME"
53+
echo "Base Ref: $BASE_REF"
54+
55+
if [ "$EVENT_NAME" = "pull_request" ]; then
56+
PR_DESCRIPTION="$(echo '${{ github.event.pull_request.body }}')"
57+
echo "PR Description: $PR_DESCRIPTION"
58+
if [[ -z "$(git log origin/$BASE_REF..HEAD --oneline --grep='Changelog-')" && \
59+
"$(git rev-parse --abbrev-ref HEAD)" != "$BASE_REF" && \
60+
"$PR_DESCRIPTION" != *"Changelog-None"* ]]; then
61+
echo "::error::'Changelog' entry is missing in all commits, and 'Changelog-None' not specified in the PR description"
62+
exit 1
63+
else
64+
echo "Changelog found."
65+
fi
66+
else
67+
echo "Not a PR event."
5368
fi
5469
5570
- name: Set up Python 3.8

0 commit comments

Comments
 (0)