Read-only actions/cache, i.e. retrieving without storing?

I’m using github actions for CI on MRs. When the MR is merged into the master, the build portion of the CI runs to generate a build cache (using actions/cache@v2) for future MRs, which significantly reduces their build time. I’m using the SHA of the git commit (${{ github.sha }}) as key: for this to work, and then inside MRs, the restore-keys uses the hash of the parent commit (the target/base).

However, in this design, when using actions/cache@v2 in pull_requests, their cache is uploaded also, even though we never subsequently use it, which wastes space and sometimes causes early eviction of git/master caches b/c of the 2GB limit. Is there some magic I can use to make an actions/cache@v2 read-only, i.e. so that MRs will use the cache of this name (as specified in restore-keys:) but don’t upload it?

1 Like

The actions/cache action has an output cache-hit that lets you know whether it found an exact match, but it doesn’t appear to have an option to attempt to retrieve the cache but not create an entry if it doesn’t.

Looks like others are asking for this feature too: Read only cache? · Issue #350 · actions/cache · GitHub

I’ve subscribed to #350 and hopefully someone will work on that at some point. I appreciate your response, thanks!

1 Like