-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
58 lines (53 loc) · 2.18 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: "Sparse Checkout"
description: "Sparse checkout a git repository, especially to speedup mono-repositories clone time"
inputs:
patterns:
description: >
Git sparse checkout patterns.
[Learn more by reading git documentation](https://git-scm.com/docs/git-sparse-checkout#Documentation/git-sparse-checkout.txt-emsetem)
default: "*"
required: true
token:
description: >
Personal access token (PAT) used to fetch the repository. The PAT is configured
with the local git config, which enables your scripts to run authenticated git
commands. The post-job step removes the PAT.
We recommend using a service account with the least permissions necessary.
Also when generating a new PAT, select the least scopes necessary.
[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
default: ${{ github.token }}
required: true
branch:
required: true
default: ${{ github.ref }}
description: >
The branch you want to check out
sha:
required: true
default: ${{ github.sha }}
description: >
The sha1 of the head commit of the branch you want to check out
runs:
using: "composite"
steps:
- name: "⚙ configure git"
shell: bash
run: |
git version
git config --global gc.auto 0
- name: "⚡ git sparse checkout latest branch commit"
shell: bash
run: |
REPO="https://${GITHUB_ACTOR}:${{ inputs.token }}@github.com/${GITHUB_REPOSITORY}.git"
INPUT_BRANCH=${{inputs.branch}}
BRANCH="${INPUT_BRANCH/#refs\/heads\//}"
git clone --filter=blob:none --no-checkout --depth 1 --sparse $REPO .
git sparse-checkout init --cone --sparse-index
git sparse-checkout set ${{ inputs.patterns }}
git -c protocol.version=2 fetch --no-tags --prune --progress --depth=1 origin +${{inputs.sha}}:refs/remotes/origin/${BRANCH}
git checkout --progress --force -B $BRANCH refs/remotes/origin/$BRANCH
- name: "👨💻 show what has been checked out"
shell: bash
run: |
git log
ls -lha