From 92064706c7749a90100a10b0b694e1480380e761 Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Mon, 4 Nov 2024 16:09:13 -0800 Subject: [PATCH] ci: Fixed handling of special characters in PR descriptions while searching for change log none. --- .github/workflows/ci.yaml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cb2d21341..8fe881db1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,25 +43,26 @@ jobs: git rebase origin/${{ github.base_ref }} - name: Check changelog + env: + PR_DESCRIPTION: "${{ github.event.pull_request.body || '' }}" + EVENT_NAME: "${{ github.event_name }}" + BASE_REF: "${{ github.base_ref || 'master' }}" run: | - EVENT_NAME="${{ github.event_name }}" - BASE_REF="${{ github.base_ref }}" - if [ -z "$BASE_REF" ]; then - BASE_REF="master" - fi echo "Event Name: $EVENT_NAME" echo "Base Ref: $BASE_REF" - + echo "PR DESCRIPTION: $PR_DESCRIPTION" if [ "$EVENT_NAME" = "pull_request" ]; then - PR_DESCRIPTION="$(echo '${{ github.event.pull_request.body }}')" - echo "PR Description: $PR_DESCRIPTION" - if [[ -z "$(git log origin/$BASE_REF..HEAD --oneline --grep='Changelog-')" && \ - "$(git rev-parse --abbrev-ref HEAD)" != "$BASE_REF" && \ - "$PR_DESCRIPTION" != *"Changelog-None"* ]]; then + if [[ "$PR_DESCRIPTION" != *"Changelog-None"* && \ + -z "$(git log origin/$BASE_REF..HEAD --oneline --grep='Changelog-')" && \ + "$(git rev-parse --abbrev-ref HEAD)" != "$BASE_REF" ]]; then echo "::error::'Changelog' entry is missing in all commits, and 'Changelog-None' not specified in the PR description" exit 1 else - echo "Changelog found." + if [[ "$PR_DESCRIPTION" == *"Changelog-None"* ]]; then + echo "Changelog found in PR description" + else + echo "Changelog found in Commit \"$(git log origin/$BASE_REF..HEAD --oneline --grep='Changelog-')\"" + fi fi else echo "Not a PR event."