I just hit a confusing compilation issue when downgrading from runs-on: ubuntu-20.04 to runs-on: ubuntu-18.04 caused because the cache didnt clear.
I'm not sure if you have access to this field, maybe something similar could be done by looking at something like lsb_release -a