Improve db readiness and build args parsing
This commit is contained in:
20
.github/workflows/docker-build-publish.yml
vendored
20
.github/workflows/docker-build-publish.yml
vendored
@@ -18,6 +18,8 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: ""
|
default: ""
|
||||||
|
description: >
|
||||||
|
Multiline build args, one per line: KEY=VALUE (values may include spaces)
|
||||||
|
|
||||||
env:
|
env:
|
||||||
description: >
|
description: >
|
||||||
@@ -121,17 +123,21 @@ jobs:
|
|||||||
BUILD_ARG_FLAGS=()
|
BUILD_ARG_FLAGS=()
|
||||||
BUILD_ARGS_JSON="{}"
|
BUILD_ARGS_JSON="{}"
|
||||||
if [ -n "$BUILD_ARGS" ]; then
|
if [ -n "$BUILD_ARGS" ]; then
|
||||||
for arg in $BUILD_ARGS; do
|
while IFS= read -r line; do
|
||||||
if [[ "$arg" != *=* ]]; then
|
trimmed="${line#"${line%%[![:space:]]*}"}"
|
||||||
echo "Invalid build arg: $arg" >&2
|
trimmed="${trimmed%"${trimmed##*[![:space:]]}"}"
|
||||||
|
[ -z "$trimmed" ] && continue
|
||||||
|
case "$trimmed" in \#*) continue;; esac
|
||||||
|
if [[ "$trimmed" != *=* ]]; then
|
||||||
|
echo "Invalid build arg: $trimmed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
BUILD_ARG_FLAGS+=(--build-arg "$arg")
|
BUILD_ARG_FLAGS+=(--build-arg "$trimmed")
|
||||||
|
|
||||||
key="${arg%%=*}"
|
key="${trimmed%%=*}"
|
||||||
val="${arg#*=}"
|
val="${trimmed#*=}"
|
||||||
BUILD_ARGS_JSON=$(jq --arg k "$key" --arg v "$val" '. + {($k): $v}' <<<"$BUILD_ARGS_JSON")
|
BUILD_ARGS_JSON=$(jq --arg k "$key" --arg v "$val" '. + {($k): $v}' <<<"$BUILD_ARGS_JSON")
|
||||||
done
|
done <<< "$BUILD_ARGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while read -r group; do
|
while read -r group; do
|
||||||
|
|||||||
23
.github/workflows/python-uv-ci.yml
vendored
23
.github/workflows/python-uv-ci.yml
vendored
@@ -146,13 +146,26 @@ jobs:
|
|||||||
--health-retries=5 \
|
--health-retries=5 \
|
||||||
postgres:16
|
postgres:16
|
||||||
for i in {1..30}; do
|
for i in {1..30}; do
|
||||||
if docker exec "$container_name" pg_isready -U postgres > /dev/null 2>&1; then
|
health="$(docker inspect --format '{{.State.Health.Status}}' "$container_name" 2>/dev/null || true)"
|
||||||
break
|
case "$health" in
|
||||||
fi
|
healthy)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
unhealthy)
|
||||||
|
echo "Postgres reported unhealthy." >&2
|
||||||
|
docker logs "$container_name" || true
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
echo "Postgres health status unavailable." >&2
|
||||||
|
docker logs "$container_name" || true
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
if ! docker exec "$container_name" pg_isready -U postgres > /dev/null 2>&1; then
|
if [ "${health:-}" != "healthy" ]; then
|
||||||
echo "Postgres did not become ready in time." >&2
|
echo "Postgres did not become healthy in time." >&2
|
||||||
docker logs "$container_name" || true
|
docker logs "$container_name" || true
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user