allow replacing stale cache - #163
Conversation
| } | ||
|
|
||
| async function deleteCachesByPrefix(prefix) { | ||
| const token = process.env.BAZELISK_GITHUB_TOKEN |
There was a problem hiding this comment.
I don't think it makes sense to use Bazelisk env var here. Let's thread token from token input to this post action via a state variable.
p0deje
left a comment
There was a problem hiding this comment.
I think your use-case is only about disk cache, right? I can see this being problematic for the repository and external caches because they are generally shared across multiple refs and are more stable. If my assumption is correct, let's change to disk-cache-replace instead.
|
|
||
| if (config.cacheReplace) { | ||
| const prefix = `${config.baseCacheKey}-${cacheConfig.name}-` | ||
| await deleteCachesByPrefix(prefix) |
There was a problem hiding this comment.
This is going to be a problem for matrix jobs - each job that runs in parallel is going to delete the other job's caches and upload them instead.
|
The use case I had in mind for this no longer applies, so I'm going to close it, but you (or anyone) is free to use/apply the code for future PRs or updates. |
Adds a new config value that deletes cache with matching prefixes before saving cache (limited to current ref).
My use case is that we only save cache from one branch, so as soon as the cache is changed we'll never need the old one, and when we are doing a lot of version bumps we're getting a lot of cache churn.
Requires
actions: writepermission on the workflow token. Requirescache-save: true(the default)Separate note, if you wanted to make this work for #18 we could add a one line replacement:
with
But I figured that was out of scope for my needs here.