How to default to GitHub hosted runners if all self-hosted runners are unavailable?

261 Views Asked by At

I have created a self-hosted runner. On my workflow, when describing the job, I use runs-on: self-hosted. But if my self-hosted runner is offline, there won't be any other runner to run that job.

Is there a way to use self-hosted runners when its online, but to let the job run on GitHub hosted runners, if no self-hosted is available?

1

There are 1 best solutions below

1
Diogo Melo On

Part of the desired behavior can be accomplished using runner groups. A GitHub runners group can have both GitHub hosted and self-hosted runners and a GitHub workflow job can be specified to run on a group:

    runs-on:
      group: hybrid-runners

If the hybrid-runners group have a self-hosted runner and a GitHub hosted runner, in each run, one of the runners will be used for that job. If the self-hosted runner is offline, then the job will necessarily default to the GitHub hosted runner.

AFAIK, there is no way to control a preferred runner and its unknown if GitHub already have a bias towards using GitHub hosted or self-hosted runners.