ci: fix docker inspect template — main branch had the wrong SHA merged
PR #1 merged 9aa96c4, which still used `.NetworkSettings.IPAddress`. That
field is empty on modern Docker (the IP is under `.Networks.<name>.IPAddress`)
and the template exits non-zero, killing the sidecar step before any test
runs. The fix landed on the PR branch as 414be71 but wasn't in the merge.
Switch to the `range .NetworkSettings.Networks` form so we pick the first
non-empty IP regardless of which bridge docker attached the container to.
This commit is contained in:
@@ -40,7 +40,16 @@ jobs:
|
|||||||
-e POSTGRES_PASSWORD=postgres \
|
-e POSTGRES_PASSWORD=postgres \
|
||||||
-e POSTGRES_DB=postgres \
|
-e POSTGRES_DB=postgres \
|
||||||
postgres:16-alpine >/dev/null
|
postgres:16-alpine >/dev/null
|
||||||
PG_IP=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' "$NAME")
|
# `.NetworkSettings.IPAddress` is empty (and template-parse errors) on
|
||||||
|
# modern Docker where the IP lives under `.Networks.<name>.IPAddress`.
|
||||||
|
# The range form picks the first non-empty IP across whatever network
|
||||||
|
# docker put the container on.
|
||||||
|
PG_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$NAME")
|
||||||
|
if [ -z "$PG_IP" ]; then
|
||||||
|
echo "postgres has no reachable IP" >&2
|
||||||
|
docker inspect "$NAME" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
echo "PG_CONTAINER=$NAME" >> "$GITHUB_ENV"
|
echo "PG_CONTAINER=$NAME" >> "$GITHUB_ENV"
|
||||||
echo "CM_TEST_DATABASE_URL=postgres://postgres:postgres@${PG_IP}:5432/postgres" >> "$GITHUB_ENV"
|
echo "CM_TEST_DATABASE_URL=postgres://postgres:postgres@${PG_IP}:5432/postgres" >> "$GITHUB_ENV"
|
||||||
for i in $(seq 1 30); do
|
for i in $(seq 1 30); do
|
||||||
|
|||||||
Reference in New Issue
Block a user