Setting the runner based on the branch

Hi,

I have something like

jobs:
  job1:
    if: github.ref == "master"
    runner: ubuntu-latest
    steps:
       HERE THE STEPS
  job2:
    if: github.ref != "master"
    runner: linux
    steps:
       HERE THE STEPS

Can I do it somehow so I can share the steps between both jobs?
I would image something like
jobs:
job1:
runner: ${{ github.ref == “master”?ubuntu-latest:linux }}
steps
HERE THE STEPS

You could try the following:

jobs:
  job1:
    runs-on: ${{ github.ref == 'refs/heads/master' && 'ubuntu-latest' || 'windows-latest' }}
...

The idea is to use just a single job, but with a runner chosen based on github.ref. Note that the ref is in the format refs/heads/<branch-or-tag>.

You could also try your approach, using mutual-exclusive conditions and two jobs:

jobs:
  job1:
    if: github.ref == 'refs/heads/master'
    runs-on: ubuntu-latest
    steps:
       ...
  job2:
    if: github.ref != 'refs/heads/master'
    runs-on: windows-latest
    steps:
       ...