From 736ec4e692c01df9e2b4512d94c9419a11f1f400 Mon Sep 17 00:00:00 2001 From: Luka Void Date: Thu, 19 Dec 2024 11:09:49 +0100 Subject: [PATCH] Update test.yml to use pull_request_target --- .github/workflows/test.yml | 55 +++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1701534..9f61089 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: Test on: push: branches: [ "main" ] - pull_request: + pull_request_target: branches: [ "main" ] schedule: - cron: "0 0 1 * *" # Runs at 00:00 on the 1st day of every month @@ -27,18 +27,27 @@ jobs: FISKALHRGO_TEST_KNOWN_ZKI: ${{ secrets.FISKALHRGO_TEST_KNOWN_ZKI }} CISTESTPRODPING: ${{ secrets.CISTESTPRODPING }} steps: - - uses: actions/checkout@v4 + - name: Checkout PR branch + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v4 + with: + # Check out the PR's head commit to test the contributor's changes + ref: ${{ github.event.pull_request.head.sha }} - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 'stable' + - name: Checkout default (non-PR) + if: ${{ github.event_name != 'pull_request_target' }} + uses: actions/checkout@v4 - - name: Build - run: go build -v ./... + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 'stable' - - name: Test - run: go test -v ./... + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... go122: runs-on: ubuntu-latest @@ -49,15 +58,23 @@ jobs: FISKALHRGO_TEST_KNOWN_ZKI: ${{ secrets.FISKALHRGO_TEST_KNOWN_ZKI }} CISTESTPRODPING: ${{ secrets.CISTESTPRODPING }} steps: - - uses: actions/checkout@v4 + - name: Checkout PR branch + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Checkout default (non-PR) + if: ${{ github.event_name != 'pull_request_target' }} + uses: actions/checkout@v4 - - name: Set up Go 1.22 - uses: actions/setup-go@v4 - with: - go-version: '1.22' + - name: Set up Go 1.22 + uses: actions/setup-go@v4 + with: + go-version: '1.22' - - name: Build - run: go build -v ./... + - name: Build + run: go build -v ./... - - name: Test - run: go test -v ./... \ No newline at end of file + - name: Test + run: go test -v ./...