-1

I have a github actions workflow which contains below snippets.

runs-on:
  - ubuntu-latest
  - some-self-hosted-runner

Is there a way to get the value of runner like ubuntu-latest or some-self-hosted-runner inside the workflow so that I can conditionally branch the steps using if, else blocks?

I did try to get runner.os. But it's not giving the expected output.

Underoos
  • 4,708
  • 8
  • 42
  • 85

1 Answers1

1

You can use matrix for scenarios like this, such as having multiple runners, needing to run different combinations etc.

jobs:
  <job-name>:
    strategy:
      matrix:
        os: [ubuntu-latest, some-self-hosted-runner]
    runs-on: ${{ matrix.os }}
    steps:
      - name: check os
        run: echo ${{ matrix.os }}
Operator
  • 109
  • 4