sbt-github-actions
sbt-github-actions copied to clipboard
Support customizing keys of default caches
Hi!
Sometimes you want to drop the cache without necessarily changing the paths it depends on, so just a "drop cache" button would be nice to have. Sadly, actions/cache doesn't have that ability (actions/cache#2), so we need a workaround.
I used this to work around, but maybe it's something that could be a key? (e.g. the cacheOffset value):
//Increment this every time you want to drop the caches
val cacheOffset = 1
ThisBuild / githubWorkflowGeneratedCacheSteps ~= { steps =>
steps.map {
case u @ WorkflowStep.Use("actions", "cache", _, params, _, _, _, _) =>
u.copy(params = params.map {
case (k @ "key", cacheKey) => (k, s"$cacheKey-v$cacheOffset")
case (k, v) => (k, v)
})
case x => x
}
}
githubWorkflowCacheOffset sounds reasonable to me. :-) It's quite the hack though! You know that it'll continue to count against your organization storage, right?
Sure... I think caches weren't my problem in this case after all 😂