Possible to use specific OS version for cache keys?
See original GitHub issueHi! We’re loving github actions so far. This is a small request related to variables available for cache keys.
We use {{ runner.os }} in our cache keys, like most of the docs here and examples I’ve seen around the internet. When ubuntu-latest was updated from 18 to 20, the build failed and I was surprised to see that it was because the cache wasn’t busted. Looking into it, {{ runner.os }} returns “Linux” (or “macOS” or similar), so it didn’t change even though our OS did. I would prefer to include the actual os version (e.g. ubuntu-20-04 or similar) in my cache keys so that the cache is busted when we change the os version. After looking around a bit, I don’t see an easy way to do this. I posted this in the community, but so far no one seems to have a workaround.
What do you all think about having runner.os_version
variable or something similar available?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:7 (1 by maintainers)
Top GitHub Comments
Hi @albaer
For info, I’ve proposed a workaround to the xrdp project where we cache a version of cppcheck. We got bitten by this too.
Have a look at the first commit neutrinolabs/xrdp@984e8d12c062e2517487198edbe040e3cdbb928b in the PR.
We’d like a better solution too! Hope this is useful in the meantime however.
Since there are a lot of folks on this thread, please note that the first step simply creates a file containing random contents and is for illustration purposes only. You would only need to copy the second step (reproduced below for your convenience) and use it in your cache step as illustrated in the third step (by referencing
${{ steps.os.outputs.image }}
). On a side note, you must specify the shell as Bash on Windows and in composite actions, the inner use ofecho
in the second step is unnecessary, and the correct key isruns-on
rather thanruns-os
.