Skip to content

GitHub action to save / restore the coursier cache of your build

License

Notifications You must be signed in to change notification settings

antonbaliasnikov/cache-action

This branch is 1 commit ahead of, 31 commits behind coursier/cache-action:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Anton Baliasnikov
Mar 24, 2023
b82ebca · Mar 24, 2023
Oct 19, 2022
Jan 9, 2023
Mar 24, 2023
May 20, 2021
Aug 14, 2020
Apr 28, 2022
Aug 17, 2020
Aug 14, 2020
Aug 14, 2020
Aug 14, 2020
Dec 14, 2022
Oct 19, 2022
Jan 9, 2023
Jan 9, 2023
Aug 14, 2020

Repository files navigation

coursier cache action

A GitHub action to save / restore the coursier / sbt / mill / Ammonite caches of your build.

Usage

Add a coursier/cache-action@v6 step to your YAML workflow, like

    steps:
      - uses: actions/checkout@v3
      - uses: coursier/cache-action@v6

Cached directories

Coursier cache

Always cached.

Add files to take into account in its cache key via extraFiles.

~/.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.

~/.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.

~/.ammonite

Cached when Ammonite scripts are found (any of *.sc, */*.sc).

Add files to take into account in its cache key via ammoniteScripts.

Parameters

root

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.

path

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

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 glob-all).

extraSbtFiles

Optional Extra sbt files to take into account in the sbt cache key. Same format as extraFiles.

extraMillFiles

Optional Extra mill files to take into account in the mill cache key. Same format as extraFiles.

ammoniteScripts

Optional Extra Ammonite scripts to take into account in the Ammonite cache key. Same format as extraFiles.

extraKey

Optional

Extra value to be appended to the coursier cache key.

See extraFiles for more details.

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.

Outputs

  • cache-hit-coursier - A boolean value to indicate a match was found for the coursier cache
  • cache-hit-sbt-ivy2-cache - A boolean value to indicate a match was found for the sbt-ivy2-cache cache
  • cache-hit-mill - A boolean value to indicate a match was found for the mill cache
  • cache-hit-ammonite - A boolean value to indicate a match was found for the ammonite cache

See Skipping steps based on cache-hit for info on using this output

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@v3

  - uses: coursier/cache-action@v6
    id: coursier-cache

  - name: Fetch Dependencies
    if: steps.coursier-cache.outputs.cache-hit-coursier != 'true'
    run: sbt +update

Note: The id defined in coursier/cache-action must match the id in the if statement (i.e. steps.[ID].outputs.cache-hit-coursier)

About

GitHub action to save / restore the coursier cache of your build

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 65.3%
  • TypeScript 34.0%
  • Scala 0.7%