I have an action which performs a SBT build with caching. I would like to be able to toggle if restore-keys are use or not (I do not want to use partial cache hits when working in master, but I want them in a feature branch). The action looks like this:
name: "SBT Build"
description: "Build the project"
inputs:
incremental:
description: Allow incremental build (uses result from previous runs)
default: "false"
required: false
runs:
using: composite
steps:
- name: Cache SBT and dependencies
uses: actions/cache@v2
id: sbt-cache
with:
path: |
~/.cache/coursier/v1
~/.sbt
project/target
project/project/target
key: ${{ runner.os }}-sbt-v2-true-${{ hashFiles('*.sbt', 'project/*.sbt', 'project/build.properties') }}
restore-keys: ${{ runner.os }}-sbt-v2-${{ inputs.incremental }}-
# .... more steps follow ...
Note: currently I use a trick of expanding inputs.incremental
into the key. When someone pass the incremental: “true”, the restore key will match the cache name. When “false” is used (which is the default), it will match nothing. It should works, but it looks ugly and I would rather skip the restore-keys or when incremental is not passed.
Is there some expresssion or something like that which would allow me to do this?