Skip to content

Commit 60a43dc

Browse files
authored
Merge pull request #668 from rancher-sandbox/host-ip-on-macos-runner
Try harder to get the external IP address on macOS Github runners
2 parents 943c90b + e5857ee commit 60a43dc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hack/test-port-forwarding.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
my $ipv4 = inet_ntoa(scalar gethostbyname(hostname())) or die;
2626
my $ipv6 = ""; # todo
2727

28+
# macOS Github runners seem to use "localhost" as the hostname
29+
if ($ipv4 eq "127.0.0.1" && $Config{osname} eq "darwin") {
30+
$ipv4 = qx(system_profiler SPNetworkDataType -json | jq -r 'first(.SPNetworkDataType[] | select(.ip_address) | .ip_address) | first');
31+
chomp $ipv4;
32+
}
33+
2834
# If $instance is a filename, add our portForwards to it to enable testing
2935
if (-f $instance) {
3036
open(my $fh, "+< $instance") or die "Can't open $instance for read/write: $!";

0 commit comments

Comments
 (0)