cache
cache copied to clipboard
Add an output to differentiate between partial and full matches
Currently outputs.cache-hit
can be used to check if an "exact match" for a cache was found and restored.
In some workflows there is a need for updating a cache entry and basically doing that continuously. E.g. for cron-task workflows where an old cache is loaded, worked on then saved and should be reused for the next cron-invoke
The current best approach to support this is:
- uses: actions/cache@v2
id: cache-test
with:
path: cacheFolder
key: cache-${{ github.run_id }}
restore-keys: cache-
This will create a unique key
per cache but restore the latest one. As long as this is run once a week the cache will "persist" long enough to be reused by the next run.
Now the problem is that a step guarded by if: steps.cache-test.outputs.cache-hit != 'true'
is always executed because it did restore a cache just not an exact hit which is by design. But now I can't run a specific step only if no cache was found at all.
So I'd like a steps.cache-test.outputs.cache-restored
output that is true when ANY cache was restored even those with partial matches
This issue is stale because it has been open for 365 days with no activity. Leave a comment to avoid closing this issue in 5 days.
Not stale
There is work going on here. There was a similar PR. You may want to track work related to granular cache control here: https://github.com/actions/cache/discussions/1020
We have added a new restore action that outputs the name of the primary key and the matched key, these outputs can be used to achieve the desired outcome. Hence closing this issue.