sbt-github-actions icon indicating copy to clipboard operation
sbt-github-actions copied to clipboard

Support customizing keys of default caches

Open kubukoz opened this issue 5 years ago • 2 comments

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
  }
}

kubukoz avatar Aug 13 '20 23:08 kubukoz

githubWorkflowCacheOffset sounds reasonable to me. :-) It's quite the hack though! You know that it'll continue to count against your organization storage, right?

djspiewak avatar Aug 14 '20 02:08 djspiewak

Sure... I think caches weren't my problem in this case after all 😂

kubukoz avatar Dec 10 '20 23:12 kubukoz