Skip to content

Sparse-checkout configuration persists across workflows on self-hosted runners #2249

@nilmond010

Description

@nilmond010

[Bug] Sparse-checkout settings from actions/checkout persist and affect subsequent workflows on self-hosted runners

Summary

When using actions/checkout with sparse-checkout on a self-hosted runner, the sparse-checkout Git configuration persists across subsequent jobs. This causes later workflows (that do not use sparse-checkout) to only check out the previously sparse file set instead of the full repository.


Prerequisite

  • A self-hosted GitHub Actions runner is configured and available.

Steps to Reproduce

  1. Run a workflow with sparse-checkout

    - name: Checkout specific file from sample-repo
      uses: actions/checkout@v4
      with:
        lfs: true
        repository: org-name/sample-repo
        token: ${{ secrets.SAMPLE_TOKEN }} # Contains a PAT
        path: sample-repo
        sparse-checkout: |
          sample-file.bak
        sparse-checkout-cone-mode: false
        clean: false

    Allow the workflow to complete.

  2. Run a second workflow on the same self-hosted runner (no sparse-checkout):

    - uses: actions/checkout@v4
      with:
        clean: true

Expected Behavior

The second workflow should check out the entire repository, unaffected by the sparse-checkout configuration from the previous workflow.


Actual Behavior

  • The second workflow:
    • Removes all files.
    • Only checks out the files that were previously specified in the sparse-checkout configuration from the first workflow.
  • This indicates that core.sparseCheckout remains set to true in the runner’s Git configuration between jobs.

Analysis

  • The actions/checkout action modifies the runner’s Git config:
    git config core.sparseCheckout true
  • On self-hosted runners, this configuration persists across jobs and workflows.
  • Unless explicitly reset, future runs on that runner inherit the sparse-checkout state.

Temporary Workaround

Manually disable sparse-checkout after using it:

- name: Disable sparse checkout
  run: git config core.sparseCheckout false
  continue-on-error: true

Proposed Fix

Ensure actions/checkout:

  1. Resets core.sparseCheckout to false at the start of each execution.
  2. Does not persist sparse-checkout state between runs on the same runner.

Reproducibility

  • 100% reproducible.
  • Can be tested without relying on our workflow execution references.

Environment

  • actions/checkout: v4
  • Runner type: Self-hosted
  • OS: Windows

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