From 0bbd5678b416a5527ddaed1e18b02ac91d726e09 Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Wed, 10 Jun 2026 21:14:39 +0200 Subject: [PATCH] fix(actions/checkout): unexpected double checkouts Signed-off-by: Emilien Escalle --- .../__test-action-checkout-issue-comment.yml | 2 +- actions/checkout/action.yml | 32 ++++--------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/.github/workflows/__test-action-checkout-issue-comment.yml b/.github/workflows/__test-action-checkout-issue-comment.yml index 0aca63f..2be6cdc 100644 --- a/.github/workflows/__test-action-checkout-issue-comment.yml +++ b/.github/workflows/__test-action-checkout-issue-comment.yml @@ -23,7 +23,7 @@ jobs: with: script: | const assert = require('node:assert/strict'); - const prNumber = 1; + const prNumber = 570; assert.ok(prNumber, 'Could not determine PR number from static test configuration'); const pr = await github.rest.pulls.get({ diff --git a/actions/checkout/action.yml b/actions/checkout/action.yml index 26dcdd1..e563d61 100644 --- a/actions/checkout/action.yml +++ b/actions/checkout/action.yml @@ -40,40 +40,22 @@ inputs: runs: using: "composite" steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - if: inputs.ref == '' && github.event_name == 'issue_comment' && inputs.persist-credentials == 'true' + - if: inputs.persist-credentials == 'false' + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: - ref: refs/pull/${{ github.event.issue.number }}/head - fetch-depth: ${{ inputs.fetch-depth }} - lfs: ${{ inputs.lfs }} - token: ${{ inputs.token || github.token }} - persist-credentials: true - - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - if: inputs.ref == '' && github.event_name == 'issue_comment' && inputs.persist-credentials != 'true' - with: - ref: refs/pull/${{ github.event.issue.number }}/head + ref: ${{ inputs.ref == '' && github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || inputs.ref }} fetch-depth: ${{ inputs.fetch-depth }} lfs: ${{ inputs.lfs }} + sparse-checkout: ${{ inputs.sparse-checkout }} token: ${{ inputs.token || github.token }} persist-credentials: false - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - if: inputs.persist-credentials == 'true' + - if: inputs.persist-credentials == 'true' + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: + ref: ${{ inputs.ref == '' && github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || inputs.ref }} fetch-depth: ${{ inputs.fetch-depth }} lfs: ${{ inputs.lfs }} sparse-checkout: ${{ inputs.sparse-checkout }} - ref: ${{ inputs.ref }} token: ${{ inputs.token || github.token }} persist-credentials: true - - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - if: inputs.persist-credentials != 'true' - with: - fetch-depth: ${{ inputs.fetch-depth }} - lfs: ${{ inputs.lfs }} - sparse-checkout: ${{ inputs.sparse-checkout }} - ref: ${{ inputs.ref }} - token: ${{ inputs.token || github.token }} - persist-credentials: false