From aaf2a4f03eaa97169243e5a4c935a2319931e25f Mon Sep 17 00:00:00 2001 From: Shivam Goyal Date: Wed, 17 Jan 2024 01:59:44 +0530 Subject: [PATCH] TP-54587 | GH Action | Validate Release PR (#9391) --- .github/workflows/validate_release_pr.yml | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/validate_release_pr.yml b/.github/workflows/validate_release_pr.yml index 081ba0563f..73d5ccedc6 100644 --- a/.github/workflows/validate_release_pr.yml +++ b/.github/workflows/validate_release_pr.yml @@ -16,8 +16,8 @@ jobs: uses: actions/checkout@v4 - name: Check if link to original PR is added in PR body run: | - ORIGINAL_PR_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -o "https://github.cmd.navi-tech.in/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") - ORIGINAL_PR_URL="https://github.cmd.navi-tech.in/${{ github.repository }}/pull/$ORIGINAL_PR_NUMBER" + ORIGINAL_PR_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -o "https://github.com/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") + 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" @@ -29,8 +29,8 @@ jobs: fi - name: Check if PR title matches original PR title run: | - ORIGINAL_PR_NUMBER=$(echo ${{ github.event.pull_request.body }} | grep -o "https://github.cmd.navi-tech.in/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") - ORIGINAL_PR_TITLE=$(curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://github.cmd.navi-tech.in/api/v3/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r .title) + ORIGINAL_PR_NUMBER=$(echo ${{ github.event.pull_request.body }} | grep -o "https://github.com/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") + ORIGINAL_PR_TITLE=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r .title) echo "PR Number extracted: $ORIGINAL_PR_NUMBER" echo "Original PR title generated: $ORIGINAL_PR_TITLE" @@ -42,9 +42,9 @@ jobs: fi - name: Check if original PR is merged in development branch run: | - ORIGINAL_PR_NUMBER=$(echo ${{ github.event.pull_request.body }} | grep -o "https://github.cmd.navi-tech.in/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") - ORIGINAL_PR_IS_MERGED=$(curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://github.cmd.navi-tech.in/api/v3/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r '.merged') - BASE_REF_BRANCH=$(curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://github.cmd.navi-tech.in/api/v3/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r '.base.ref') + ORIGINAL_PR_NUMBER=$(echo ${{ github.event.pull_request.body }} | grep -o "https://github.com/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") + ORIGINAL_PR_IS_MERGED=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r '.merged') + BASE_REF_BRANCH=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r '.base.ref') if [[ "$ORIGINAL_PR_IS_MERGED" == "true" && "$BASE_REF_BRANCH" == "development" ]]; then echo "Original PR is merged into development branch" else @@ -56,11 +56,11 @@ jobs: fi - name: Check if current PR changes are subset of original PR changes run: | - ORIGINAL_PR_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -o "https://github.cmd.navi-tech.in/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") - ORIGINAL_PR_COMMITS=$(curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://github.cmd.navi-tech.in/api/v3/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER/commits" | jq -r '.[].sha') + ORIGINAL_PR_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -o "https://github.com/${{ github.repository }}/pull/[0-9]*" | grep -o "[0-9]*") + ORIGINAL_PR_COMMITS=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER/commits" | jq -r '.[].sha') ORIGINAL_PR_FILES=() for COMMIT_SHA in $ORIGINAL_PR_COMMITS; do - COMMIT_FILES=$(curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://github.cmd.navi-tech.in/api/v3/repos/${{ github.repository }}/commits/$COMMIT_SHA" | jq -r '.files[].filename') + COMMIT_FILES=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/commits/$COMMIT_SHA" | jq -r '.files[].filename') ORIGINAL_PR_FILES+=($COMMIT_FILES) done ORIGINAL_PR_FILES=$(echo "${ORIGINAL_PR_FILES[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') @@ -70,10 +70,10 @@ jobs: echo "Original PR files: $ORIGINAL_PR_FILES" CURRENT_PR_NUMBER="${{ github.event.pull_request.number }}" - CURRENT_PR_COMMITS=$(curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://github.cmd.navi-tech.in/api/v3/repos/${{ github.repository }}/pulls/$CURRENT_PR_NUMBER/commits" | jq -r '.[].sha') + CURRENT_PR_COMMITS=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$CURRENT_PR_NUMBER/commits" | jq -r '.[].sha') CURRENT_PR_FILES=() for COMMIT_SHA in $CURRENT_PR_COMMITS; do - COMMIT_FILES=$(curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://github.cmd.navi-tech.in/api/v3/repos/${{ github.repository }}/commits/$COMMIT_SHA" | jq -r '.files[].filename') + COMMIT_FILES=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/commits/$COMMIT_SHA" | jq -r '.files[].filename') CURRENT_PR_FILES+=($COMMIT_FILES) done CURRENT_PR_FILES=$(echo "${CURRENT_PR_FILES[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')