From 95661c0ae8933c814a41642d9982d2ff08759df9 Mon Sep 17 00:00:00 2001 From: Shivam Goyal Date: Fri, 14 Feb 2025 12:28:52 +0530 Subject: [PATCH] NTP-1234 | Shivam | Fix Compose Master PR CI (#14976) --- .github/workflows/release-pr.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index c7e23c0bbf..7b6acf33b6 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -34,18 +34,21 @@ jobs: if: always() run: | CURRENT_PR_BODY=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq -r '.body') + echo "CURRENT_PR_BODY: $CURRENT_PR_BODY" echo "CURRENT_PR_BODY=$CURRENT_PR_BODY" >> $GITHUB_ENV + CURRENT_PR_NUMBER=${{ github.event.pull_request.number }} + echo "CURRENT_PR_NUMBER: $CURRENT_PR_NUMBER" + echo "CURRENT_PR_NUMBER=$CURRENT_PR_NUMBER" >> $GITHUB_ENV + ORIGINAL_PR_NUMBER=$(echo $CURRENT_PR_BODY | grep -o "https://github.com/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") + echo "ORIGINAL_PR_NUMBER: $ORIGINAL_PR_NUMBER" echo "ORIGINAL_PR_NUMBER=$ORIGINAL_PR_NUMBER" >> $GITHUB_ENV - name: Verification Step 1 - link to master PR is added in release PR body if: always() run: | ORIGINAL_PR_URL="https://github.com/${{ github.repository }}/pull/$ORIGINAL_PR_NUMBER" - - echo "Original PR Number extracted: $ORIGINAL_PR_NUMBER" - echo "Original PR Url generated: $ORIGINAL_PR_URL" - echo "Current PR body: $CURRENT_PR_BODY" + echo "ORIGINAL_PR_URL: $ORIGINAL_PR_URL" if [[ "$CURRENT_PR_BODY" != *"$ORIGINAL_PR_URL"* ]]; then echo "Link to original PR raised against master branch not found in current PR body" @@ -54,13 +57,13 @@ jobs: - name: Verification Step 2 - release PR title matches master PR title if: always() run: | + CURRENT_PR_TITLE=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$CURRENT_PR_NUMBER" | jq -r .title) + echo "CURRENT_PR_TITLE: $CURRENT_PR_TITLE" + ORIGINAL_PR_TITLE=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r .title) + echo "ORIGINAL_PR_TITLE: $ORIGINAL_PR_TITLE" - echo "PR Number extracted: $ORIGINAL_PR_NUMBER" - echo "Original PR title generated: $ORIGINAL_PR_TITLE" - echo "Current PR title extracted: ${{ github.event.pull_request.title }}" - - if [[ "${{ github.event.pull_request.title }}" != "$ORIGINAL_PR_TITLE" ]]; then + if [[ "$CURRENT_PR_TITLE" != "$ORIGINAL_PR_TITLE" ]]; then echo "Current PR title does not match original PR title raised against master branch" exit 1 fi @@ -87,7 +90,7 @@ jobs: files_pr_master=$(echo "$response_pr_master" | jq -r '.[].filename') # Get the JSON response for the second pull request - response_pr_release=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files") + response_pr_release=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$CURRENT_PR_NUMBER/files") files_pr_release=$(echo "$response_pr_release" | jq -r '.[].filename') # Compare the lists of changed files