Skip to content

Commit

Permalink
Use merge base when calculating changed files (#16709)
Browse files Browse the repository at this point in the history
`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: #16709
  • Loading branch information
KyleFromNVIDIA committed Aug 30, 2024
1 parent c6c720f commit 5e420ff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- '**'
Expand Down

0 comments on commit 5e420ff

Please sign in to comment.