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:
This “action” needs to take place on every runner that the action has access to.
I hope this makes sense!
A workflow run is made up of one or more jobs , which run in parallel by default. To run jobs sequentially, you can define dependencies on other jobs using the jobs.
To install multiple self-hosted runner on your host, you should use different workdir and different runner name. The registration token can be identical( or you can rerun the api command to get a new one).
Communication between self-hosted runners and GitHubThe application must be running on the machine to accept and run GitHub Actions jobs. Since the self-hosted runner opens a connection to GitHub.com, you do not need to allow GitHub to make inbound connections to your self-hosted runner.
This may include tasks like building separate portions of a site, running tests on multiple versions, etc. To do all of this, GitHub Actions has the concept of jobs to run a series of actions and commands within a self-contained environment. To start, Let's run a linter & tests for a hypothetical node library at the same time.
You could force that by using unique runner labels. By defining unique label on a runner you can then reference that runner in both jobs with runs-on Will I accomplish this better with a composite action rather than using a reusable workflow?
You can use GitHub Actions as a way to run a cron job script, which they’ll run for you for free (as long as you stay within the monthly limits ). Let’s say I’m creating a GitHub Action that runs a Node.js script on a schedule. I’ll call the Action “Scheduled Job”, but you can call it whatever you’d like.
Use workflows to run multiple jobs. A workflow run is made up of one or more jobs, which run in parallel by default. To run jobs sequentially, you can define dependencies on other jobs using the jobs.<job_id>.needs keyword. Each job runs in a runner environment specified by runs-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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With