Simpler way to run steps only for a single platform

I have some conditions in my steps like:

if: matrix.os == 'ubuntu-latest'

It feels clunky having to repeat “ubuntu-latest” in many places when really what I want to say is just “linux”. If I was running on multiple versions of Ubuntu or in the future if there were non-Ubuntu linux options, it would be weird to have to maintain all of these.

Is there some way we could have a field that represents the platform (“win”, “mac”, “linux” or similar)?

(I just found some people doing “startsWith(, ‘linux’)” which looks slightly better - but still weird, especially as I think it needs to Ubuntu, not Linux).

if: runner.os == 'Linux'

if: runner.os == 'Windows'

if: runner.os == 'macOS'

Looks like runner.os is not documented, I’m wondering if this should be the official way to do it.

We haven’t finalized the documentation for the runner context yet, but you should be able to safely rely on runner.os.