9

I need to figure out the local IP address of Github runner, which uses macOS 11. I need this for my integration tests.

I tried:

LOCAL_IP=ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'
SERVER_URL="http://${LOCAL_IP}:5000"

However, this gave me just: http://:5000

Which is the correct command for this?

user3439894
  • 58,676
DarkMath
  • 193
  • 1
  • 1
  • 5
  • Related https://apple.stackexchange.com/questions/60160/how-can-i-find-my-ip-address-not-my-companys-router-but-my-local-machines, but the answers there are not easily useable in a script. – nohillside Jun 26 '21 at 12:04
  • I know that there are many related questions, but I do not find any answer for a solution based on shell script. – DarkMath Jun 26 '21 at 12:20
  • Are these scripts running on the same machine as the server? If not is the server on a fixed machine? – mmmmmm Jun 26 '21 at 13:10
  • I have a mono repository containing a python backend (flask) and a Flutter app. I've written end-to-end tests and now I want them to run in the pipeline. Therefore, I wrote a Github action file that starts the backend and after that the flutter integration tests. For this I need the IP of the backend, which runs locally on the MacOS Github runner. – DarkMath Jun 26 '21 at 13:13
  • I have two questions 1)Do you really need to write this as a script? For a one-off discovery it would be far easier to just look in the Network control Panel. 2) is this inside the same Mac? If so, then it's always 127.0.0.1. – Tetsujin Jun 26 '21 at 17:42
  • Yes. This is a Github runner which have no UI and I cannot connect to it. All I can do is executing a script with Github actions. 2) The app runs on an android virtual device. Therefore, 127.0.0.1 points to the virtual device, not to the mac where my backend is.
  • – DarkMath Jun 26 '21 at 18:02
  • I honestly understood none of that;) so I'll step aside. – Tetsujin Jun 26 '21 at 18:44
  • Then you need to look at the documentation of the app that provides the VM (e.g. virtualbox, docker ...) andsee how it sets up its network – mmmmmm Jun 27 '21 at 09:35
  • I didn't find anything in the documentation: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#about-self-hosted-runners and here https://github.com/actions/virtual-environments – DarkMath Jun 27 '21 at 14:07