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 }}
The
checkoutaction documentation have few examples demonstrating how to fetch specific files.You can also use
checkout-filesaction to checkout only certain files and/or folders. This action uses Github REST API to download the repository content.Here the
filesis a list of files with the path separated by a space, relative to root of your repository. This can also be a folder and the action will recursively pull all the files.