-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: false
Allow 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.sparseCheckout
remains set totrue
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
:
- Resets
core.sparseCheckout
tofalse
at 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