Running a job on every runner in GitHub Actions

3.6k Views Asked by At

For those that are familiar with Github Actions...

At present, when a job runs, it picks the most suitable runner for the job based on labels and repository (Using self-hosted runners in a workflow - GitHub Docs). My question is whether it is possible to run a single job on every runner that’s meets the requirements of a job.

For example, I have multiple runners, both self-hosted and hosted by Github; I have a job that contains a script that does the following when code is pushed to the repo:

  • Checks out the Git repo using actions/checkout@v2
  • Copies a file from the checked out repo to a user’s home directory

This “action” needs to take place on every runner that the action has access to.

I hope this makes sense!

1

There are 1 best solutions below

1
On

According to official documentation you should use strategy option in your job, where you can define on which machine you want your job to run.

Although I didn't find specific use-case for combining github and self-hosted runners, I'd try something like this:

strategy:
  matrix:
    os: [ubuntu-18.04, ubuntu-20.04, self-hosted]
runs-on: ${{ matrix.os }}
steps:
  - uses: actions/checkout@v2