Search code examples
cachinggithub-actions

Github Actions - multiple cache with same key


I'm trying to maintain separate caches for each build environment (qa, staging, prod). So that whenever I try to build for the QA environment, a particular cache is used to speed up the build process. I'm triggering this build workflow by creating a release.

My problem is while retrieving the cache in the cache step, the cache is always missed and it creates a new cache every time with the same key. My cache key is ${{ runner.os }}-buildx-${{ env.deploy_env }}. When I look at GitHub cache page. I see multiple caches with the same key.

What am I missing here? Any help is appreciated

enter image description here


Solution

  • Workflows can only restore caches from a base branch, the current branch or the default branch. It's hard to tell from the screenshot, but if those caches are from different tags, that is why there is more than one cache.