From 5e420ff63ba2997a37bf5dfbfaa73c5f05225f9d Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 30 Aug 2024 17:44:03 -0400 Subject: [PATCH] Use merge base when calculating changed files (#16709) `get-pr-info.outputs.base.sha` does not actually give the merge base, but merely the tip of the target branch. Calculate the merge base and pass it to the `changed-files` step. Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - Ray Douglass (https://github.com/raydouglass) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/cudf/pull/16709 --- .github/workflows/pr.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 35c7e3d95b6..0d79568f589 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -56,14 +56,21 @@ jobs: - name: Checkout code repo uses: actions/checkout@v4 with: - ref: ${{ inputs.sha }} - fetch-depth: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).commits }} + fetch-depth: 0 persist-credentials: false + - name: Calculate merge base + id: calculate-merge-base + env: + PR_SHA: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).head.sha }} + BASE_SHA: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }} + run: | + (echo -n "merge-base="; git merge-base "$BASE_SHA" "$PR_SHA") > "$GITHUB_OUTPUT" - name: Get changed files id: changed-files uses: tj-actions/changed-files@v45 with: - base_sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }} + base_sha: ${{ steps.calculate-merge-base.outputs.merge-base }} + sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).head.sha }} files_yaml: | cpp: - '**'