cache icon indicating copy to clipboard operation
cache copied to clipboard

Cache not caching on pull_request

Open ManuLpz4 opened this issue 3 years ago • 5 comments

Hi guys! How it's going? Hope you are doing well :)

Simply that, I test all the scenarios and I found that cache is caching only on push :/

ManuLpz4 avatar Sep 04 '21 19:09 ManuLpz4

Can you provide more details? Maybe a code snippet?

You may find your answer in here: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache

A workflow can access and restore a cache created in the current branch, the base branch (including base branches of forked repositories), or the default branch (usually main). For example, a cache created on the default branch would be accessible from any pull request.

Access restrictions provide cache isolation and security by creating a logical boundary between different branches. For example, a cache created for the branch feature-a (with the base main) would not be accessible to a pull request for the branch feature-b (with the base main).

andrmoel avatar Sep 16 '21 21:09 andrmoel

@andrmoel thank you! So what do you think its a good approach for caching and save minutes on pull requests ci?

Now we cache on push to development branch but it takes a bit more than a minute to complete the cache when hits a preexistent cache :/

ManuLpz4 avatar Sep 30 '21 06:09 ManuLpz4

@ManuLpz4 a cache created on the default branch would be accessible from any pull request. What problems were you facing? Are you using a different branch other than the default branch against which PRs are raised? Can you put in more details?

vsvipul avatar Feb 25 '22 07:02 vsvipul

Hello ! I think I've just hit the same issue, we run self-hosted runners, and I wanted to cache things between sequential jobs on a PR workflow (store the scan result, then use the result to process it later) It seems that every time I tried storing/pulling the cache, I ended with Cache not found for input keys Seems that the only viable solution is artifact upload/download ? There might be a shared filesystem alternative

Gby56 avatar Apr 12 '22 08:04 Gby56

Not allowing cache across PR branches is by design to not allow cache poisoning by a malicious PR. You can still use cache from base branch (or even the default branch) in the pull request branches.

bishal-pdMSFT avatar Jul 01 '22 08:07 bishal-pdMSFT