Skip to content

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

Open
@jmlord

Description

@jmlord

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'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions