diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ab65db..ab5c03e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -235,8 +235,12 @@ jobs: - name: Name the address the job can reach the published ports on run: | set -eu - GW=$(ip route | awk '/default/ {print $3; exit}') - [ -n "$GW" ] || { echo "no default route out of the job container"; exit 1; } + # `ip` is not in this image (measured: `ip: command not found`, exit 127), + # so the route is read from the kernel's own table. The gateway there is + # hex, little-endian, and bash turns it back into dotted quad. + GWHEX=$(awk '$2=="00000000" {print $3; exit}' /proc/net/route) + [ -n "$GWHEX" ] || { echo "no default route in /proc/net/route"; exit 1; } + GW=$(printf '%d.%d.%d.%d' "0x${GWHEX:6:2}" "0x${GWHEX:4:2}" "0x${GWHEX:2:2}" "0x${GWHEX:0:2}") echo "OPENWAF_EDGE_HOST=$GW" >> "$GITHUB_ENV" echo "the gate will ask the edge at $GW" @@ -363,8 +367,12 @@ jobs: - name: Name the address the job can reach the published ports on run: | set -eu - GW=$(ip route | awk '/default/ {print $3; exit}') - [ -n "$GW" ] || { echo "no default route out of the job container"; exit 1; } + # `ip` is not in this image (measured: `ip: command not found`, exit 127), + # so the route is read from the kernel's own table. The gateway there is + # hex, little-endian, and bash turns it back into dotted quad. + GWHEX=$(awk '$2=="00000000" {print $3; exit}' /proc/net/route) + [ -n "$GWHEX" ] || { echo "no default route in /proc/net/route"; exit 1; } + GW=$(printf '%d.%d.%d.%d' "0x${GWHEX:6:2}" "0x${GWHEX:4:2}" "0x${GWHEX:2:2}" "0x${GWHEX:0:2}") echo "OPENWAF_EDGE_HOST=$GW" >> "$GITHUB_ENV" echo "the gate will ask the edge at $GW"