I'm building some reusable workflows, and one of my workflows requires some specific prerequisite software to exist on the runner. I have a self-hosted runner pool I can use, and for those runners the prerequisite software is already on the runner servers. I can also use a pool of runners another group in my organization makes available, but for this other pool the runners don't have the prerequisite software, so I specify a container that will have the prerequisite software.
So I want to be able to specify a container when my workflow is running on group2, but not specify any container when it is running on group1.
Is there a way to make the container be optional in the workflow YAML definition? I don't want to duplicate the job and have conditional logic that runs one or the other just to allow one to use container
and the other to not.
It seems like I can have either:
runs-on:
group: 'group1'
steps:
...
Or
runs-on:
group: 'group2'
container:
image: 'myregistry.com/my-image-with-prerequisites-installed:latest'
steps:
...
But is there a way to have a single YAML file that will work for both? I want to choose the runner group as an input, and when the input group is 'group1' it uses no container, but when the input groups is 'group2' it uses a container--and without having to duplicate job configuration in the YAML.