Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All files are checked out even sparse-checkout option for single file #1550

Open
jmlord opened this issue Nov 17, 2023 · 3 comments
Open

All files are checked out even sparse-checkout option for single file #1550

jmlord opened this issue Nov 17, 2023 · 3 comments

Comments

@jmlord
Copy link

jmlord commented Nov 17, 2023

When trying to checkout single file from root of remote repo, the sparse-checkout option appears to be pulling all files from that branch.

    - uses: actions/checkout@v4
      with:
        # Repository name with owner. For example, actions/checkout
        # Default: ${{ github.repository }}
        repository: 'GEO-BON/bon-in-a-box-pipeline-engine.git'

        # The branch, tag or SHA to checkout. When checking out the repository that
        # triggered a workflow, this defaults to the reference or SHA for that event.
        # Otherwise, uses the default branch.
        ref: 'pipeline-repo-actions'

        # Relative path under $GITHUB_WORKSPACE to place the repository
        path: '.server'

        # Do a sparse checkout on given patterns. Each pattern should be separated with
        # new lines.
        # Default: null
        sparse-checkout: |
          prod-server.sh

    - name: Temp
      working-directory: .
      run: ls -la .server
      shell: bash

I would expect that the ls above will show only one file plus .git folder. Instead, we get the following:

Run ls -la .server
total 92
drwxr-xr-x  3 runner docker  4096 Nov 17 19:22 .
drwxr-xr-x 10 runner docker  4096 Nov 17 19:22 ..
-rw-r--r--  1 runner docker    69 Nov 17 19:22 .dev-paths.env
drwxr-xr-x  8 runner docker  4096 Nov 17 19:22 .git
-rw-r--r--  1 runner docker   930 Nov 17 19:22 .gitattributes
-rw-r--r--  1 runner docker    69 Nov 17 19:22 .gitignore
-rw-r--r--  1 runner docker    61 Nov 17 19:22 .prod-paths.env
-rw-r--r--  1 runner docker    89 Nov 17 19:22 .test-paths.env
-rw-r--r--  1 runner docker  1064 Nov 17 19:22 LICENSE
-rw-r--r--  1 runner docker  6285 Nov 17 19:22 README-dev.md
-rw-r--r--  1 runner docker 17396 Nov 17 19:22 README-user.md
-rw-r--r--  1 runner docker   454 Nov 17 19:22 README.md
-rw-r--r--  1 runner docker  1446 Nov 17 19:22 compose.dev.yml
-rw-r--r--  1 runner docker   517 Nov 17 19:22 compose.prod.yml
-rw-r--r--  1 runner docker  2480 Nov 17 19:22 compose.yml
-rwxr-xr-x  1 runner docker   486 Nov 17 19:22 dev-server.sh
-rwxr-xr-x  1 runner docker  5290 Nov 17 19:22 prod-server.sh

Note that the above gives the same result with sparse-checkout: 'prod-server.sh'.

@cyb3rko
Copy link

cyb3rko commented Dec 21, 2023

It appears I can replicate this problem

@boshoff
Copy link

boshoff commented Jan 18, 2024

Looking at the actions/checkout documentation, you need to specify sparse-checkout-cone-mode: false if you only want to check-out a single file.

@jmlord
Copy link
Author

jmlord commented Jan 18, 2024

Looking at the actions/checkout documentation, you need to specify sparse-checkout-cone-mode: false if you only want to check-out a single file.

Thanks for the link! It's indeed very clear in this example. However, in the documentation of the parameters themselves, nothing states that sparse-checkout cannot be used on its own.

# Do a sparse checkout on given patterns. Each pattern should be separated with
# new lines.
# Default: null
sparse-checkout: ''

# Specifies whether to use cone-mode when doing a sparse checkout.
# Default: true
sparse-checkout-cone-mode: ''

I would expect either sparse checkout to automatically trigger that option, or that it be explicitly documented in the parameter description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants