diff --git a/.github/workflows/validate_release_pr.yml b/.github/workflows/validate_release_pr.yml index 73d5ccedc6..03d0d16e2c 100644 --- a/.github/workflows/validate_release_pr.yml +++ b/.github/workflows/validate_release_pr.yml @@ -3,18 +3,20 @@ name: Validate Release PR CI on: pull_request: branches: [ release-* ] + types: [ opened, edited, reopened, synchronize ] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: - validate-pr: + validate-release-pr: runs-on: [ default ] steps: - name: Checkout Repository uses: actions/checkout@v4 - - name: Check if link to original PR is added in PR body + - name: Verification Step 1 - Link to development PR is added in release PR Body + if: always() run: | 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" @@ -27,7 +29,8 @@ jobs: echo "Link to original PR raised against development branch not found in current PR body" exit 1 fi - - name: Check if PR title matches original PR title + - name: Verification Step 2 - release PR Title matches development PR Title + if: always() run: | 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) @@ -40,11 +43,13 @@ jobs: echo "Current PR title does not match original PR title raised against development branch" exit 1 fi - - name: Check if original PR is merged in development branch + - name: Verification Step 3 - development PR is Merged + if: always() run: | 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 @@ -54,7 +59,8 @@ jobs: echo "Status: Fail. Original PR is not merged in development branch." exit 1 fi - - name: Check if current PR changes are subset of original PR changes + - name: Verification Step 4 - release PR is subset of development PR + if: always() run: | 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')