Sparse-checkout configuration persists across workflows on self-hosted runners
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.9k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
[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
-
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: falseAllow the workflow to complete.
-
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.sparseCheckoutremains set totruein the runner’s Git configuration between jobs.
Analysis
- The
actions/checkoutaction 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:
- Resets
core.sparseCheckouttofalseat the start of each execution. - 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by tracing actions/checkout's sparse-checkout configuration handling and reproduce the two-workflow sequence on a self-hosted Windows runner. Done means a later checkout without sparse-checkout restores the full repository instead of inheriting the earlier sparse file set.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github-actions, typescript
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100