GitHub:Actions:actions/cache
lastmod 2022-12-06created 2022-12-062 edits
Cache dependencies and build outputs in GitHub Actions
hashFiles
Example with a single pattern
Matches any package-lock.json file in the repository.
Example with multiple patterns
Creates a hash for any package-lock.json and Gemfile.lock files in the repository.
Matching a cache key
In restore-keys you can specify a list of alternate restore keys to use when there is a cache miss. You can create multiple restore keys ordered from the most specific to the least specific. The action searches them in sequential order. When a restore-keys key doesn't match directly, the action searches for keys prefixed with the restore key. If there are multiple partial matches for a restore key, the action returns the most recently created cache.
Example
The runner evaluates the expressions, which resolve to:
The restore key npm-feature- matches any key that starts with the same string. For example, both keys npm-feature-fd3052de and npm-feature-a9b253ff match the restore key. The cache with the most recent creation date is used.
The keys in this example are searched in the following order.
-
npm-feature-d5ea0750matches a specific hash. -
npm-feature-matches cache keys prefixed withnpm-feature-. -
npm-matches any keys prefixed withnpm-.
See also
Favorite site
- Github - actions/cache
- Caching dependencies to speed up workflows - GitHub Docs
- Python caching in GitHub Actions | AI2 | AI2 Blog
- Caching dependencies for speed | TechWell