Replies: 2 comments
-
Ignore the below - looks like my testing missed that it was actually the second restore ket I was hitting not the first.
steps:
- uses: actions/cache@v2
with:
path: cached.txt
key: ${{ github.ref }}-${{ github.sha }}
restore-keys: |
**-${{ github.sha }}
${{ github.ref }}-
|
Beta Was this translation helpful? Give feedback.
-
Raised #740 but there doesn't seems to be much feedback from actual GitHub people on issues in there. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I'd quite like to cache by SHA and by branch name, so that if I tag a commit that has already been built on a branch then it uses the cache for that commit to rebuild it, but if I build a branch then I benefit from a cache populated from the previous build on that branch.
Is that possible?
If I use this cache key
${{ github.ref }}-${{ github.sha }}
then the branch run will cache asmain-abcdef
and the tag run will look up with0.1.0-abcdef
and it will miss.If I use this cache key
${{ github.sha }}-${{ github.ref }}
then the branch build will cache asabcdef-main
, the tag build will look up withabcdef-0.1.0
and it will hit theabcdef
SHA cache, but a subsequent commit to main will look up with123456-main
and miss.I suppose I'd really like to cache it under two keys - once under
${{ github.ref }}
and once under${{github.sha}}
. Then I can use this:and (I think!) it'll use the SHA cache for preference and fall back to the branch name cache if there's no SHA cache. But I don't think caching under two keys is supported? Am I wrong?
Anyone got a nice solution to this?
Beta Was this translation helpful? Give feedback.
All reactions