Skip to content

Commit d9186b7

Browse files
authored
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.
1 parent c58c35d commit d9186b7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

action.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ runs:
5252
ref: ${{ inputs.base_ref }}
5353
path: gitstream/repo/
5454
token: ${{ fromJSON(fromJSON(inputs.client_payload)).githubToken || github.token }}
55+
fetch-depth: 1
5556

5657
- name: Escape single quotes
5758
id: safe-strings
@@ -125,16 +126,21 @@ runs:
125126
ARTIFACT_OUTCOME_CM_REPO_ARG: ${{ steps.download-cache-for-cm-repo.outcome }}
126127
with:
127128
script: require('${{ github.action_path }}/scripts/check-cache-download-status')(core);
128-
129+
129130
- name: Checkout Pull Request branches history
130131
if: ${{ env.SHOULD_CHECKOUT == 'true' }}
131132
shell: bash
133+
env:
134+
# Use 1 for shallow fetch when SKIP_FULL_HISTORY is non‐empty,
135+
# otherwise default to 2147483647 for effectively unlimited
136+
DEPTH: ${{ env.SKIP_FULL_HISTORY && 1 || 2147483647 }}
132137
run: |
133-
ALL=2147483647
134-
cd gitstream && cd repo
135-
git fetch --deepen=$ALL origin $'${{ steps.safe-strings.outputs.base_ref }}'
138+
cd gitstream/repo
139+
140+
# both origin and upstream use the same DEPTH
141+
git fetch --deepen=$DEPTH origin $'${{ steps.safe-strings.outputs.base_ref }}'
136142
git remote add upstream $'${{ steps.safe-strings.outputs.url }}'
137-
git fetch --deepen=$ALL upstream $'${{ steps.safe-strings.outputs.head_ref }}'
143+
git fetch --deepen=$DEPTH upstream $'${{ steps.safe-strings.outputs.head_ref }}'
138144
git checkout -b $'upstream/${{ steps.safe-strings.outputs.head_ref}}' $'upstream/${{ steps.safe-strings.outputs.head_ref}}'
139145
git checkout $'${{ steps.safe-strings.outputs.base_ref }}'
140146
git checkout $'${{ steps.safe-strings.outputs.head_ref }}'

0 commit comments

Comments
 (0)