Prerequisites
In order to usenscloud-cache-action, you need to ensure that a cache volume is attached to the GitHub Actions job.
Check out the Cache Volumes guide
for details.
When using a package manager or toolchain cache mode (for example npm, pnpm, or go), the manager or toolchain must be installed before the cache
action runs, otherwise the step fails. This does not apply to caching arbitrary files with path.
It is important to run the cache action after the checkout action in the workflow sequence. Checkout action automatically wipes the workspace directory, so it would remove the cached content and prevent new content from being stored on the cache volume.
Examples
- Select languages and frameworks
- Cache arbitrary files
Options
detect
string A list of cache modes to enable only if detected in the environment. Set to true to detect all available cache modes. See cache for a list of available cache modes.
Optional.
cache
string A list caching modes to enable. Currently supported languages/frameworks are:
- Apt
- Bun
- CocoaPods
- Composer
- Deno
- Go
- GolangCI-Lint
- Gradle
- Homebrew
- Maven
- Mise
- Nix
- NPM
- Playwright
- PNPM
- Poetry
- Python
- Ruby
- Rust
- SwiftPM
- UV
- Xcode
- Yarn
AptCache mode
apt caches downloaded APT packages on the attached Cache Volume.The apt-config executable must be available before namespacelabs/nscloud-cache-action is called.path.
path
string A list of files, directories, to cache and restore. ~ is resolved to $HOME. Can be used in concert with cache.
${{ runner.temp }} cannot be cached as this directory is emptied at the beginning and end of each job.
fail-on-cache-miss
boolean If enabled, fail the workflow if the path is not found on the cache volume.
Advanced: Running GitHub Jobs in Containers
We recommend using a separate profile for your workflows that run in containers.GitHub Actions run as user runner by default. Running in a container can change the user. Sharing caches from different users may lead to permission errors when accessing the cache.Details →
- The Cache Volume path
/cachemust be mounted into the container. - The env var
NSC_CACHE_PATHmust be set. - Container needs to have
SYS_ADMINcapability, so that the cache action has permissions to call themountcommand. - The
sudo,mkdirandchownbinaries must be available in the container image, or must be installed.
This action relies on specific properties of the environment and may require tuning to work with images that significantly diverge from Ubuntu. Please reach out to us at support@namespace.so for assistance.