tespkg / actions-cache

Cache to S3 storage with official actions/cache@v2 fallback
MIT License
75 stars 31 forks source link

fix cache-hit output when match isn't exact #19

Closed Balvajs closed 2 years ago

Balvajs commented 2 years ago

The original actions/cache action is setting cache-hit to true only if the cache key was exact match:

restore-keys - An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note cache-hit returns false in this case.

So this PR fixes the behavior and sets the cache-hit output to true just only if the cache key is exact match.

Also persist key inside state, so it's not re-evaluated in post action. And change restore so it prioritizes cache matched with key over restore-keys.

jackieli-tes commented 2 years ago

Hi @Balvajs , thanks very much for the contribution. All looks good. I just had to do some quick formatting. Merging after pipeline run