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

sparse-checkout not working when running in a container. #1602

Open
nuryupin-kr opened this issue Feb 2, 2024 · 2 comments
Open

sparse-checkout not working when running in a container. #1602

nuryupin-kr opened this issue Feb 2, 2024 · 2 comments

Comments

@nuryupin-kr
Copy link

nuryupin-kr commented Feb 2, 2024

I'm using actions/checkout@v4
Sparce checkout parameter doesn't have any effect when running job in a container.

It works fine when running directly on an ubuntu self-hosted runner. But when I tried running using debian or alpine image, it checks out the entire repo.

My guess that it has to do with Git being present in the container.

The logs for Alpine/Debian containers look like this:

Getting Git version info
Deleting the contents of '/__w/my-repo/my-repo'
The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
Downloading the archive
Writing archive to disk
Extracting the archive
<extracting using tar>
Resolved version <my-repo>

Logs when using a runner directly:

Getting Git version info
Temporarily overriding HOME='/runner/_work/_temp/guid' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
/usr/bin/git config --global --add safe.directory /runner/_work/my-repo/my-repo
Deleting the contents of '/runner/_work/my-repo/my-repo'
Initializing the repository
Disabling automatic garbage collection
Setting up auth
Fetching the repository
Determining the checkout info
Setting up sparse checkout
Checking out the ref
/usr/bin/git log -1 --format='%H
@nuryupin-kr nuryupin-kr changed the title sparse-checkout not working when using container. sparse-checkout not working when running in a container. Feb 2, 2024
@Ayanmullick
Copy link

Ayanmullick commented Apr 11, 2024

I'm facing the same problem. It isn't working inside a container image; it shows the entire repository. However, it's working fine if I don't use a container.

name: AzurePowerShellScript
on: [workflow_dispatch]
jobs:
  Resources:
    runs-on: ubuntu-latest  
    container: mcr.microsoft.com/azure-powershell:latest  

    steps:
    - name: Check Out
      uses: actions/checkout@v4                      
      with:
        sparse-checkout-cone-mode:  false           
        sparse-checkout: |                          
          GHActionTest/                             
          3TierApp/
    - name: TestStep
      shell: pwsh
      run: Get-ChildItem -Recurse  #Shows only checked out repo. contents when not using the container image.

Is sparse-checkout expected to work inside containers? Could this be a Git version\configuration mismatch with the image?

Setting a variable in $Env:GITHUB_OUTPUT and retrieving it in another job also doesn't work when using a container image. I'm not sure if that's related or if it should be a separate issue.

@Karelian-na
Copy link

I also encountered this problem.
After I looked at the implementation of actions/checkout, I found that sparse-checkout needs the git version newer than 2.28, then i tried to upgrade the git version to latest, it worked well

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