From 9de66bb51f9cc3e768c22c93d4b40846b67206a6 Mon Sep 17 00:00:00 2001 From: Kyle Squizzato Date: Fri, 18 Oct 2024 11:24:48 -0700 Subject: [PATCH] Get the PR ref during checkout instead of using 'main' Signed-off-by: Kyle Squizzato --- .github/workflows/build_test.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index c524221d8..db1972af8 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -31,9 +31,20 @@ jobs: version: ${{ steps.vars.outputs.version }} clustername: ${{ steps.vars.outputs.clustername }} steps: + - name: Get PR ref + uses: actions/github-script@v6 + id: pr + with: + script: | + const { data: pullRequest } = await github.rest.pulls.get({ + ...context.repo, + pull_number: context.payload.pull_request.number, + }); + return pullRequest - name: Checkout repository uses: actions/checkout@v4 with: + ref: ${{fromJSON(steps.pr.outputs.result).merge_commit_sha}} fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v5