Possible to get specific os version for cache keys?

We use {{ runner.os }} in our cache keys, like most of the docs 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, but it feels like I’m missing something obvious here. Anyone have any leads?

1 Like

Hi, I’m not quite sure if we have a workaround for this. Can we ask that you open an issue here if you have not already?

The maintainers of actions/cache may have a workaround.

With that being said, if other GitHub users reading this have found additional workarounds, we’d be grateful if you shared them with us!

Thanks for the nudge! I opened an issue here: Possible to use specific OS version for cache keys? · Issue #543 · actions/cache · GitHub