-
Hi, Is it possible to get the name of the runner on which a job is executed? At the workflow yaml level or at the job / step level. I have 4 bare metal servers on which I run container base tests. In the docs, I see there is only:
|
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
Technically, you could probably retrieve it from its own logs. But practically, I’d just use You could also probably add an extra environment variable. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. I have this job. The steps are executed inside the container… and I can’t see how to tell GitHub Action that I want a step to be executed on the docker-host / Ubuntu.
|
Beta Was this translation helpful? Give feedback.
-
You could add another job |
Beta Was this translation helpful? Give feedback.
-
That second job might end up running on a different runner though, so it won’t reliably say which runner the container is on. |
Beta Was this translation helpful? Give feedback.
-
I ended up with this option: Each docker-engine hosts bare-metal has a file with default container variables /srv/docker/default.env Inside that variable it can have the URL to various services The /srv/docker/default.env file is managed outside of GitHub Actions/Workflow. The workflow looks like this.
I also implemented a simple rendevous service in which each container will access an URL like http://services.local/container-services and the page will return a list of service depending on the remote/source IP of the http client… Basically this was a more complex version of what is my ip :slight_smile: |
Beta Was this translation helpful? Give feedback.
-
Oops, I forgot about that! Would giving each self-hosted runner a unique label and using the same machine for both jobs work? (Ideally choosing a random machine for the first job, and then picking the same for the second) |
Beta Was this translation helpful? Give feedback.
-
I don’t know about unique labels… looks complicated and I don’t understand how it works. having the runner name in the GitHub context would have been perfect, |
Beta Was this translation helpful? Give feedback.
-
@Simran-B Trying to make a live example from your suggestion this is the possible example:
|
Beta Was this translation helpful? Give feedback.
I ended up with this option:
Each docker-engine hosts bare-metal has a file with default container variables
/srv/docker/default.env
Inside that variable it can have the URL to various services
The /srv/docker/default.env file is managed outside of GitHub Actions/Workflow.
The workflow looks like this.