From 4360d9d2ad58fe7ac098a9267f310fa64d7ed189 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 16 Aug 2023 00:11:23 +0100 Subject: [PATCH] ci: use pull request head commit whenever possible The `github.sha` is a merge commit with the parents of latest master and the head of the pr. Trying to diff the changes from that merge SHA to base will show all changes that have been made in-between. And that doesn't seem about right. We switch to `github.event.pull_request.head.sha` if there is a pr. See: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/version-bump.20CI.20failing --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 61d11d54e17..2e71f14b88f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -87,7 +87,7 @@ jobs: runs-on: ubuntu-latest env: BASE_SHA: ${{ github.event.pull_request.base.sha }} - HEAD_SHA: ${{ github.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.head.sha || github.sha }} steps: - uses: actions/checkout@v3 with: