I’m banging my head against the desk trying to figure out the correct syntax for my workflow YAML. I am using a container on a self-hosted runner and I would like to specify the hostname for the container. This works:
jobs:
myjob:
runs-on: [ self-hosted, ubuntu, dataplatform ]
container:
image: image:tag
options: --hostname myhostname
However I want to specify it dynamically by setting hostname to the value of GITHUB_RUN_NUMBER and I can’t figure out how to do it.
This:
jobs:
myjob:
runs-on: [ self-hosted, ubuntu, dataplatform ]
container:
image: image:tag
options: --hostname $GITHUB_RUN_NUMBER
just sets hostname to the literal value “$GITHUB_RUN_NUMBER”, here is what gets returned from running docker inspect
on the container
So I tried this instead:
jobs:
myjob:
runs-on: [ self-hosted, ubuntu, dataplatform ]
container:
image: image:tag
options: --hostname ${{ env.GITHUB_RUN_NUMBER }}
but that just caused an error when attempting to start the workflow:
[ Invalid workflow file : .github/workflows/demo.yml#L29]
The workflow is not valid. .github/workflows/demo.yml (Line: 29, Col: 16): Unrecognized named-value: ‘env’. Located at position 1 within expression: env.GITHUB_RUN_NUMBER
Please can someone tell me the correct syntax to refer to env vars in jobs.<job_id>.container.options
?