I'm using github actions runner on windows.
I tried the below to checkout only the scripts
folder from remote repo called betech
from branch mm365
inside the current-folder\betech
; but it checks out the entire repo contents.
- name: Checkout just the scripts folder
uses: actions/checkout@v3
with:
repository: mytech/betech
ref: mm365
path: betech
token: ${{ secrets.MYGITHUBTOKEN }}
- name: Configure Sparse Checkout
run: |
echo "scripts/*" >> .git/info.sparse-checkout
git read-tree -mu HEAD
working-directory: betech
env:
token: ${{ secrets.MYGITHUBTOKEN }}
secrets: inherit
here is the sparse file
cat betech\.git\info.sparse-checkout
scripts/*
Can you please suggest how I can checkout only the scripts folder or any single file [If the logic is comparatively different]
*** Update: *** I tied the below answer and it works.
- name: Checkout just the scripts folder
uses: actions/checkout@v3
with:
repository: mytech/betech
ref: mm365
path: betech
sparse-checkout: |
scripts
sparse-checkout-cone-mode: false
token: ${{ secrets.MYGITHUBTOKEN }}
checkout
action documentation have few examples demonstrating how to fetch specific files.
- uses: actions/checkout@v3 with: sparse-checkout: .Fetch only the root files and
.github
andsrc
folder- uses: actions/checkout@v3 with: sparse-checkout: | .github src
- uses: actions/checkout@v3 with: sparse-checkout: | README.md sparse-checkout-cone-mode: false
You can also use checkout-files
action to checkout only certain files and/or folders. This action uses Github REST API to download the repository content.
- name: Checkout files
uses: Bhacaz/checkout-files@v2
with:
files: package.json