Skip to content
Latchkey

sccache GitHub Actions Cache Backend

sccache can store its cache in the GitHub Actions cache service, sharing hits across workflow runs without external storage.

On GitHub Actions you do not need S3 to get a shared compiler cache: sccache speaks to the Actions cache service directly when you enable the GHA backend and expose the right tokens.

What it does

With SCCACHE_GHA_ENABLED=true, sccache uses the GitHub Actions cache as its storage backend. It needs the Actions cache runtime token and URL, which the official mozilla-actions/sccache-action sets up for you, or which you export from ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL via the toolkit.

Common usage

Terminal
# env for the build steps
export SCCACHE_GHA_ENABLED=true
export CMAKE_C_COMPILER_LAUNCHER=sccache
export CMAKE_CXX_COMPILER_LAUNCHER=sccache
# typically set up by mozilla-actions/sccache-action, which also
# exports ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL for sccache
sccache --show-stats

Options

VariableWhat it does
SCCACHE_GHA_ENABLED=trueUse the GitHub Actions cache backend
ACTIONS_RUNTIME_TOKENAuth token for the Actions cache service
ACTIONS_CACHE_URLEndpoint of the Actions cache service
SCCACHE_GHA_VERSIONCache version/namespace to bust on toolchain changes

In CI

The simplest setup is the mozilla-actions/sccache-action step plus SCCACHE_GHA_ENABLED=true and the two compiler-launcher variables; it wires the tokens for you. Bump SCCACHE_GHA_VERSION when the compiler or major deps change so stale entries are not reused. Read sccache --show-stats at the end of the job to confirm hits.

Common errors in CI

"Error: The cache backend GHA is not configured" or token errors mean ACTIONS_RUNTIME_TOKEN/ACTIONS_CACHE_URL are not exported into the build steps; use the sccache-action or export them via the toolkit. Forks and some events restrict the Actions cache token, so hits silently drop to zero on those runs. A 400/403 from the cache service usually means an expired or missing token.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →