From d9186b771e3bdb0bf3c74f98c9a97c43bae1f60a Mon Sep 17 00:00:00 2001 From: Vincent Lussenburg Date: Fri, 13 Jun 2025 14:04:39 -0400 Subject: [PATCH 1/2] Add SKIP_FULL_HISTORY to skip fetch the entire git history For monorepos fetch the entire history can take excessively long. If no automations are used that use git history, this can be skipped now. --- action.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 9e09661e..fea71f6d 100644 --- a/action.yml +++ b/action.yml @@ -52,6 +52,7 @@ runs: ref: ${{ inputs.base_ref }} path: gitstream/repo/ token: ${{ fromJSON(fromJSON(inputs.client_payload)).githubToken || github.token }} + fetch-depth: 1 - name: Escape single quotes id: safe-strings @@ -125,16 +126,21 @@ runs: ARTIFACT_OUTCOME_CM_REPO_ARG: ${{ steps.download-cache-for-cm-repo.outcome }} with: script: require('${{ github.action_path }}/scripts/check-cache-download-status')(core); - + - name: Checkout Pull Request branches history if: ${{ env.SHOULD_CHECKOUT == 'true' }} shell: bash + env: + # Use 1 for shallow fetch when SKIP_FULL_HISTORY is non‐empty, + # otherwise default to 2147483647 for effectively unlimited + DEPTH: ${{ env.SKIP_FULL_HISTORY && 1 || 2147483647 }} run: | - ALL=2147483647 - cd gitstream && cd repo - git fetch --deepen=$ALL origin $'${{ steps.safe-strings.outputs.base_ref }}' + cd gitstream/repo + + # both origin and upstream use the same DEPTH + git fetch --deepen=$DEPTH origin $'${{ steps.safe-strings.outputs.base_ref }}' git remote add upstream $'${{ steps.safe-strings.outputs.url }}' - git fetch --deepen=$ALL upstream $'${{ steps.safe-strings.outputs.head_ref }}' + git fetch --deepen=$DEPTH upstream $'${{ steps.safe-strings.outputs.head_ref }}' git checkout -b $'upstream/${{ steps.safe-strings.outputs.head_ref}}' $'upstream/${{ steps.safe-strings.outputs.head_ref}}' git checkout $'${{ steps.safe-strings.outputs.base_ref }}' git checkout $'${{ steps.safe-strings.outputs.head_ref }}' From a524a17827f7895a773cab5977d69260d5b981b6 Mon Sep 17 00:00:00 2001 From: Vincent Lussenburg Date: Fri, 13 Jun 2025 11:59:05 -0700 Subject: [PATCH 2/2] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index fea71f6d..e69491d9 100644 --- a/action.yml +++ b/action.yml @@ -126,7 +126,7 @@ runs: ARTIFACT_OUTCOME_CM_REPO_ARG: ${{ steps.download-cache-for-cm-repo.outcome }} with: script: require('${{ github.action_path }}/scripts/check-cache-download-status')(core); - + - name: Checkout Pull Request branches history if: ${{ env.SHOULD_CHECKOUT == 'true' }} shell: bash