Skip to content

Sticky disks

A sticky disk is a block device kept between jobs for one repository, for build tools with their own on-disk caches. Asking for one, using it, and guarding for its absence.

Last updated

A job gets a fresh virtual machine every time, which is the property that makes one customer's build unable to observe another's. It is also why a build tool with its own on-disk cache starts cold on every run.

A sticky disk is a second block device attached to the job and kept between jobs for the same repository. The root filesystem is still new every time; only this disk persists.

Sticky disks are off until you turn them on. An owner, an admin or a billing member turns them on in Settings → Runners → Add-ons, with Turn on sticky disks; you can turn them off from the same card. Other members see the card but cannot change it.

While this is on, Ubuntu x64 jobs of 1 to 16 vCPU run only on our own servers, so they may wait longer when those are busy.

A disk is billed storage, so your organisation needs a card on file first. Without one the card sends you to Billing instead of offering the button.

The setup wizard also asks, on the step where you pick repositories, with the box ticked and the same terms beside it. If you have not added a card yet, your answer is kept and sticky disks start when you add one; until then nothing is stored or billed, and the card in Add-ons reads Waiting for a card, with a button to take the answer back.

Before you press it, the card tells you what you are agreeing to: the price, that it is billed on what you actually store, that a repository's disk unused for 7 days is deleted, how much your organisation can keep, and that you can turn it off. If the price or the cap changes while the page is open, the press is refused and the card reloads with the new figures.

It takes effect within a couple of minutes. The card reads Turning on until then and On once a build can get a disk. Until it is on, no job gets a disk, RUNNERSIO_STICKY_DISK is empty, and nothing is charged for one.

A build that starts in the first minutes can still be handed a machine that was prepared before you pressed the button, and that one has no disk. If RUNNERSIO_STICKY_DISK is empty in a build right after you turn them on, the next one gets it.

Your organisation can keep up to 100 GB of sticky disks. The card shows what is stored against that, measured every hour from the same figure your bill is built from, so it can be up to an hour behind.

At the cap your builds still run with their disks, but nothing more is kept until you delete some (reset a repository's disk) or ask us to raise the cap.

New builds stop getting a disk. What is already stored is billed until it is deleted, which is 7 days after its last use, or sooner if you reset the repository's disk.

When a job has a sticky disk it is mounted before your steps run and the path is in the environment as RUNNERSIO_STICKY_DISK. Point a tool's cache directory at it:

yaml
jobs:
  build:
    runs-on: runnersio-8vcpu-ubuntu-2404
    steps:
      - uses: actions/checkout@v4
      - name: Build
        env:
          GOCACHE: ${{ env.RUNNERSIO_STICKY_DISK }}/go-build
          GOMODCACHE: ${{ env.RUNNERSIO_STICKY_DISK }}/go-mod
        run: go build ./...

The disk every job gets needs no action and no token to configure; any further disks are added with an action. The disk is ext4, owned by the runner user, and yours to lay out however you like.

Guard on the variable rather than on the path. RUNNERSIO_STICKY_DISK is set only when a disk was actually mounted, so a step that reads it gets an empty value on a job without one, and a script that hardcodes the mount point will write into the root filesystem instead and quietly lose the cache:

bash
CACHE_DIR="${RUNNERSIO_STICKY_DISK:-$RUNNER_TEMP}/gradle"
mkdir -p "$CACHE_DIR"

A disk that cannot be prepared does not fail the job. The build runs without it and is merely slower — a cache is an optimisation, and failing a build over one would be the wrong trade.

Anything that keeps a cache on disk and is slow to rebuild. Point the disk at a tool's cache directories, never at a whole home directory or a tool's whole configuration directory:

  • Bazel's output base and repository cache

  • Gradle's ~/.gradle/caches and Maven's ~/.m2/repository

  • Cargo's /usr/local/cargo/registry and /usr/local/cargo/git (on our runners CARGO_HOME is /usr/local/cargo, not ~/.cargo), and target/

  • Go's build and module caches (GOCACHE, GOMODCACHE)

  • node_modules for a very large install

Never put a credential on a sticky disk. Later builds of the repository start from what is on it, and not all of them are as trusted as the one that wrote it. That is why the list above names Cargo's registry rather than the whole of CARGO_HOME, which also holds credentials.toml. The same goes for ~/.npmrc, ~/.docker/config.json, ~/.gradle/gradle.properties and any cloud CLI's configuration directory: keep them off the disk, and keep anything a step writes from a secret there too.

If one gets there anyway, or you think the disk holds something it should not, reset it.

The checkout cache is one more thing that can live on the disk: with runners-io/checkout@v1 in place of actions/checkout, a mirror of the repository is kept under .runners-io/ on the disk, so a job fetches only what the repository gained. It counts against the disk's cap and is billed as storage like everything else on the disk; leave .runners-io/ alone.

Package manager stores lists where npm, pnpm, Yarn, pip, Go, Gradle, Maven and others keep their downloads, and how to put each on a disk of its own.

For dependency archives that restore cheaply from a keyed tarball, the Actions cache is simpler and is included. For Docker image layers specifically, the layer cache is the right mechanism.

A job can have up to five more disks, each with a name you choose: add runners-io/stickydisk with a key and a path for each one.

yaml
jobs:
  build:
    runs-on: runnersio-4vcpu-ubuntu-2404
    steps:
      - uses: actions/checkout@v4
      - uses: runners-io/stickydisk@v1
        with:
          key: ${{ github.repository }}-npm
          path: ~/.npm
      - uses: runners-io/stickydisk@v1
        with:
          key: ${{ github.repository }}-pip
          path: ~/.cache/pip
      - run: npm ci

The first time a key appears its disk starts empty and nothing from that run is saved; the next run of the job attaches an empty disk for that key and saves what it writes if it is a successful run of your default branch, and the run after that starts warm.

A key belongs to one repository and one runner image: the same key in two repositories is two disks.

Every disk counts toward the same storage total and the same 100 GB limit, at the same price on what is actually stored. The total is measured once an hour, so a run that saves to several disks can pass the limit by more than a run that saves to one.

A disk whose key has not been used for 7 days is deleted, and resetting a repository's disk empties all of its disks.

One default disk per repository and runner image, plus any named disks you add. Two repositories never share one, and neither do two organisations — it is attached to the VM as a device, and a job can reach only the one attached to it.

A repository's jobs on ubuntu-24.04 and on ubuntu-22.04 therefore each get a disk of their own. What a build leaves on a disk — toolchains, virtualenvs, compiled caches — is built against one image's libraries and paths, so a disk written on 24.04 is never mounted on 22.04, nor the other way round. Each image's disk is saved on its own, under the rules below, so a build on one image never changes what the other starts from. A reset of the repository's disk empties all of its images' disks. A repository that has only ever run on one image has only one disk. A Windows, ARM or 32 vCPU job gets no sticky disk and runs with an empty one (which labels get one).

Every job gets its own copy. When several jobs of the same repository run at once, each one is given its own private copy of the disk as it was last saved, on whichever machine it lands. Jobs never share a live disk, and nobody waits for anybody else to finish with it. A matrix that fans out ten jobs gives all ten the warm cache.

A job's changes become what later jobs start from only if its copy is saved (see which builds keep their changes). When several builds that may save finish close together, they are saved one after another and the last one wins: each later build starts from whichever was saved last. A build whose change was still waiting to be saved when a later one of the same branch finished is dropped in favour of the later one, and the disk's history says so.

You can tell whether a disk was mounted from inside the job: RUNNERSIO_STICKY_DISK is set only when one was, so a step that reads it gets an empty value on a job that ran without one. That is rare -- it happens only when one of our machines is short of space for the copy -- and the job then runs without the cache rather than waiting or failing.

Never treat a sticky disk as shared mutable state between concurrent jobs: each sees only the last saved state, never what a job running beside it writes.

The first build of the default branch on a new repository formats it, so treat that run as cold.

A disk is reclaimed after seven days without a job attaching it, and once it is gone it is not billed. Attaching resets the clock, so a repository that builds even weekly keeps its disk; one that stops building loses it, and the next build after that starts cold and formats a new one. Nothing is deleted while a job is holding it.

Nothing here is durable, and that is the design rather than a limitation: everything on a sticky disk must be reconstructible by the build. If losing it would break you, it belongs in an artefact store or a registry.

A sticky disk is state every later build of the repository starts from, so which builds may change it is decided on our side, not by your workflow file. In short:

  • A successful build of your default branch, started by a trusted trigger such as a push or a schedule, keeps what it leaves, unless what it changed holds a credential or could not be checked in time.

  • Every other build of a branch of the repository works on a private copy that is thrown away, or, in a protected repository, on an empty disk.

  • A build from a fork, a build that runs a tag, and a build whose workflow run we could not read get no disk at all.

Protecting a sticky disk has the whole of it: the exact triggers, the credentials we refuse to keep, the record of which build changed the disk, resetting it, and protected repositories.

A sticky disk is metered by what it stores, on the blocks actually used rather than on the size the disk reports. The pricing page has the rate.