actions/cache step is needed. See the complete language workflow examples.
What the action caches
Put the cache step after checkout and before any build step. Turn off the cache built into setup actions, such as
cache: false for actions-rust-lang/setup-rust-toolchain and actions/setup-go, and package-manager-cache: false for actions/setup-node.
To cache other directories, list them in paths:
How caching works
Before your build, the action downloads the job’s cache from the volume and unpacks it to the runner’s local disk, so builds never read the volume directly. After a successful job, it saves the cache if your lockfiles or toolchain changed, and waits until the upload finishes. Each branch and pull request has its own cache. A job restores its own cache first; a pull request then falls back to its base branch, and every job falls back to your default branch. Jobs save only to their own cache, so a pull request that doesn’t change dependencies reuses the default branch’s cache and saves nothing. Branch and pull request caches are deleted after a week without use. Jobs share a cache when they run the same job of the same workflow; setkey to separate matrix entries that build different things:
Cache scope and persistence
Jobs and branches share one cache volume per project, GitHub connection, and repository. The volume is mounted read-write atTENSORLAKE_CACHE_DIR, so code in a pull request can write to it directly. Keep secrets out of cached paths.
For a small cache of a few large files, you can still use the volume directly by writing into a subdirectory of TENSORLAKE_CACHE_DIR. Changes persist after a job finishes; forced termination can discard recent writes. Use GitHub artifacts for outputs you need to keep.
See the action’s README for every input.