I have two sets of self-hosted GitHub runners that run the same action. I need to run slightly different steps on each set, triggered by conditions.
- Set 1: All names begin with
foo-
- Set 2: All names vary
Runner names of the second set vary by design, so I want to avoid specifying runner names in the if:
conditions, even though this condition works:
if: contains(runner.name, 'some-runner-name')
Instead, I want to trigger specific steps when runner.name
DOES NOT contain foo-
.
I have tried a few variants of these to accomplish this, but the steps do not get picked up on the desired runner when I compare what contains()
returns with an operator like == 'false'
or != true
:
- if: contains(runner.name, 'foo-') == 'false'
run: echo "Hello World!"
shell: bash
- if: contains(runner.name, 'foo-') != 'true'
run: echo "Hello World!"
shell: bash
How can I properly use the contains(runner.name, 'foo-')
function with an expression to set a condition?