See: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
In general, Java programs are not affected by the version of the operating system, so we should always use the latest version. By the way, it seems that we are missing a GitHub action runner for Ubuntu 18.04(see here), which has been deprecated.