Skip to content

Commit 7fdfe72

Browse files
ci: Fix for searching change log in PR description with special characters
1 parent f63de5e commit 7fdfe72

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,26 @@ jobs:
4343
git rebase origin/${{ github.base_ref }}
4444
4545
- name: Check changelog
46+
env:
47+
PR_DESCRIPTION: "${{ github.event.pull_request.body || '' }}"
48+
EVENT_NAME: "${{ github.event_name }}"
49+
BASE_REF: "${{ github.base_ref || 'master' }}"
4650
run: |
47-
EVENT_NAME="${{ github.event_name }}"
48-
BASE_REF="${{ github.base_ref }}"
49-
if [ -z "$BASE_REF" ]; then
50-
BASE_REF="master"
51-
fi
5251
echo "Event Name: $EVENT_NAME"
5352
echo "Base Ref: $BASE_REF"
54-
53+
echo "PR DESCRIPTION: $PR_DESCRIPTION"
5554
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
55+
if [[ "$PR_DESCRIPTION" != *"Changelog-None"* && \
56+
-z "$(git log origin/$BASE_REF..HEAD --oneline --grep='Changelog-')" && \
57+
"$(git rev-parse --abbrev-ref HEAD)" != "$BASE_REF" ]]; then
6158
echo "::error::'Changelog' entry is missing in all commits, and 'Changelog-None' not specified in the PR description"
6259
exit 1
6360
else
64-
echo "Changelog found."
61+
if [[ "$PR_DESCRIPTION" == *"Changelog-None"* ]]; then
62+
echo "Changelog found in PR description"
63+
else
64+
echo "Changelog found in Commit \"$(git log origin/$BASE_REF..HEAD --oneline --grep='Changelog-')\""
65+
fi
6566
fi
6667
else
6768
echo "Not a PR event."

0 commit comments

Comments
 (0)