Skip to content

docs(readme): add a runner setup that empties the workspace per job - #10

Merged
dennis-tra merged 1 commit into
mainfrom
docs/runner-clean-workspace
Nov 11, 2026
Merged

dennis-tra merged 1 commit into
mainfrom
docs/runner-clean-workspace

Conversation

@dennis-tra

Copy link
Copy Markdown
Contributor

What and why

The self-hosted runners reuse the clone of a repo from one job to the next, and actions/checkout keeps what an earlier job wrote to .git/config. In atlas, the Cloudflare purge jobs use sparse-checkout, which makes a partial clone (blob:none). After such a job, every checkout with lfs: true in the same workspace failed with Could not scan for Git LFS files / missing object, on all three runners.

This adds the section "Set up a runner" under "Runners" in the README:

  • A job-started hook (ACTIONS_RUNNER_HOOK_JOB_STARTED) empties the workspace, so each job starts with a new clone, as on a GitHub-hosted runner.
  • The Git LFS files go to a cache per runner user outside the workspace (lfs.storage), so a new clone does not download them again. A weekly cron job deletes files that no job read in 14 days.
  • Limits: what the hook does not clean, root-owned files from container: jobs, and no git lfs prune in jobs.

The section uses RUNNER_USER instead of machine and user names, because this repo is public.

How I checked it

  • The hook script, copied from the README: it empties a folder that has a .git folder and files, and exits 0 when GITHUB_WORKSPACE is unset or the folder does not exist. shellcheck passes.
  • git lfs env with a global lfs.storage shows the LFS object folder at the new path. The source of actions/checkout@v7 copies the runner user's ~/.gitconfig into its temporary home, so checkout uses the setting.
  • The cron snippet passes bash -n.
  • just ci passes.
  • Not tested on a runner: the .env hook line, the cron job and the svc.sh restart.

Deploy

Nothing for the workflows. To apply it, follow the new steps on the runner machine, then check that a job log shows the hook in the step "Set up runner".

A self-hosted runner reuses the clone of a repo from one job to the
next, so a setting in .git/config reaches the next job. In atlas, a
job with sparse-checkout left a partial clone (blob:none), and the
next checkout with lfs: true failed with "missing object".

The new section "Set up a runner" adds a job-started hook that empties
the workspace, and keeps the Git LFS files in a shared cache outside
it (lfs.storage), so a new clone does not download them again.
@dennis-tra
dennis-tra merged commit 954e59d into main Nov 11, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

1 participant