coursier/cache-action
{ "createdAt": "2020-08-14T16:07:01Z", "defaultBranch": "main", "description": "GitHub action to save / restore the coursier cache of your build", "fullName": "coursier/cache-action", "homepage": "", "language": "TypeScript", "name": "cache-action", "pushedAt": "2026-03-17T09:32:39Z", "stargazersCount": 65, "topics": [], "updatedAt": "2026-03-17T00:20:55Z", "url": "https://github.com/coursier/cache-action"}coursier cache action
Section titled “coursier cache action”A GitHub action to save / restore the coursier / sbt / mill / Ammonite caches of your build.
Add a coursier/cache-action@v7 step to your YAML workflow, like
steps: - uses: actions/checkout@v5 - uses: coursier/cache-action@v7Cached directories
Section titled “Cached directories”Coursier cache
Section titled “Coursier cache”Always cached.
Add files to take into account in its cache key via [extraFiles]!(#extrafiles).
~/.sbt and ~/.ivy2/cache
Section titled “~/.sbt and ~/.ivy2/cache”Cached when sbt files are found (any of *.sbt, project/**.scala, project/**.sbt, project/build.properties).
Add files to take into account in its cache key via [extraSbtFiles]!(#extrasbtfiles).
~/.cache/mill
Section titled “~/.cache/mill”Cached when mill files are found (any of .mill-version, ./mill).
Add files to take into account in its cache key via [extraMillFiles]!(#extramillfiles).
~/.ammonite
Section titled “~/.ammonite”Cached when Ammonite scripts are found (any of *.sc, */*.sc).
Add files to take into account in its cache key via [ammoniteScripts]!(#ammonitescripts).
Parameters
Section titled “Parameters”Optional Root directory containing build definition sources (build.sbt, build.sc, etc.)
If the sbt or mill build definition files are in a sub-directory, pass the path to this sub-directory here.
Optional Override for the path of the coursier cache.
By default, the coursier cache is assumed to be in the default OS-dependent location.
Set this input to override that. Note that this action will also set the COURSIER_CACHE environment variable
if an override is specified, so that you don’t have to set it yourself.
extraFiles
Section titled “extraFiles”Optional Extra files to take into account in the cache key.
By default, sbt build definition files (*.sbt, project/**.{scala,sbt}, project/build.properties) and
mill build definition files (*.sc, ./mill) are hashed to uniquely identify the cached data. Upon
cache restoration, if an exact match is found, the cache is not saved again at the end of the job.
In case of no exact match, it is assumed new files may have been fetched; the previous cache for the
current OS, if any, is restored, but a new cache is persisted with a new key at the end of the job.
To take into account extra files in the cache key, pass via extraFiles either
- a single path as a string
- multiple paths in a JSON array, encoded in a string
Blobs are accepted (processed by @actions/glob).
extraSbtFiles
Section titled “extraSbtFiles”Optional Extra sbt files to take into account in the sbt cache key. Same format as extraFiles.
extraMillFiles
Section titled “extraMillFiles”Optional Extra mill files to take into account in the mill cache key. Same format as extraFiles.
ammoniteScripts
Section titled “ammoniteScripts”Optional Extra Ammonite scripts to take into account in the Ammonite cache key. Same format as extraFiles.
extraKey
Section titled “extraKey”Optional
Extra value to be appended to the coursier cache key.
See extraFiles for more details.
extraHashedContent
Section titled “extraHashedContent”Optional
Extra content to take into account in the cache key.
See extraFiles for more details.
The content of extraHashedContent is taken into account in the hash for the coursier cache key.
ignoreJob
Section titled “ignoreJob”Optional
Default: false
Set true if you don’t want to use a job id as part of cache key.
ignoreMatrix
Section titled “ignoreMatrix”Optional
Default: false
Set true if you don’t want to use a matrix jobs as part of cache key.
ignoreAmmonite
Section titled “ignoreAmmonite”Optional
Default: false
Set true to skip saving and restoring the Ammonite cache, regardless of whether the repository contains .sc scripts.
Cache invalidation
Section titled “Cache invalidation”To manually invalidate the cache without changing your build files, set the COURSIER_CACHE_ACTION_CACHE_VERSION
environment variable in your workflow. Changing its value produces a different cache key across all
cache types, so the old cache is ignored and a fresh one is created.
The variable can be set at the workflow level so that it applies to every step:
env: COURSIER_CACHE_ACTION_CACHE_VERSION: 1 # increment this value to invalidate the cache
steps: - uses: actions/checkout@v5 - uses: coursier/cache-action@v7Or it can be scoped to only the coursier/cache-action step:
steps: - uses: actions/checkout@v5 - uses: coursier/cache-action@v7 env: COURSIER_CACHE_ACTION_CACHE_VERSION: 1 # increment this value to invalidate the cacheThis is equivalent to passing the version as extraHashedContent, but more convenient because it
can be set globally for the whole workflow (or even as a repository variable / secret) without
touching the individual step configuration.
Outputs
Section titled “Outputs”cache-hit-coursier- A boolean value to indicate a match was found for the coursier cachecache-hit-sbt-ivy2-cache- A boolean value to indicate a match was found for the sbt-ivy2-cache cachecache-hit-mill- A boolean value to indicate a match was found for the mill cachecache-hit-ammonite- A boolean value to indicate a match was found for the ammonite cache
See [Skipping steps based on cache-hit]!(#Skipping-steps-based-on-cache-hit) for info on using this output
Skipping steps based on cache-hit
Section titled “Skipping steps based on cache-hit”Using the cache-hit-... outputs above, subsequent steps can be skipped when a cache hit occurs on a given key.
Example:
steps: - uses: actions/checkout@v5
- uses: coursier/cache-action@v7 id: coursier-cache
- name: Fetch Dependencies if: steps.coursier-cache.outputs.cache-hit-coursier != 'true' run: sbt +updateNote: The
iddefined incoursier/cache-actionmust match theidin theifstatement (i.e.steps.[ID].outputs.cache-hit-coursier)