Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
server

GitHub Action

Choose Action Runner

v1

Choose Action Runner

server

Choose Action Runner

Choose self-hosted action runner based on their availability

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Choose Action Runner

uses: QCDIS/choose-action-runner@v1

Learn more about this action in QCDIS/choose-action-runner

Choose a version

Choose Action Runner

This action checks if some self-hosted runners are online. If they are offline, it falls back to, e.g. GithHub hosted runners. Self-hosted runners are selected based on their name (not label!), for compatibility with runner scale sets. We add the possibility to check from runners from the repository (default), or the organization through the runners-holder parameter.

The GitHub API token should have the following permission:

  • read access to organization self-hosted runners
  • read access to repository administration and metadata

Usage

jobs:

  choose-runner:
    runs-on: ubuntu-latest
    outputs:
      runner: ${{ steps.choose-runner.outputs.runner }}
    steps:
      - id: choose-runner
        uses: QCDIS/choose-action-runner@v1
        with:
          preferred-runner: my-selfhosted-runner
          fallback-runner: ubuntu-latest
          github-token: ${{ secrets.REPO_ACCESS_TOKEN }}

  do-something:
    needs: [choose-runner]
    runs-on: ${{ needs.choose-runner.outputs.runner }}
    steps:
      - name: Do something
        run: |
          echo "Running on ${{ needs.choose-runner.outputs.runner }}"

Acknowledgements

https://github.com/marketplace/actions/check-runner-availability https://github.com/orgs/community/discussions/20019#discussioncomment-7173595