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
|
||||
type: string
|
||||
default: ""
|
||||
description: >
|
||||
Multiline build args, one per line: KEY=VALUE (values may include spaces)
|
||||
|
||||
env:
|
||||
description: >
|
||||
@@ -121,17 +123,21 @@ jobs:
|
||||
BUILD_ARG_FLAGS=()
|
||||
BUILD_ARGS_JSON="{}"
|
||||
if [ -n "$BUILD_ARGS" ]; then
|
||||
for arg in $BUILD_ARGS; do
|
||||
if [[ "$arg" != *=* ]]; then
|
||||
echo "Invalid build arg: $arg" >&2
|
||||
while IFS= read -r line; do
|
||||
trimmed="${line#"${line%%[![:space:]]*}"}"
|
||||
trimmed="${trimmed%"${trimmed##*[![:space:]]}"}"
|
||||
[ -z "$trimmed" ] && continue
|
||||
case "$trimmed" in \#*) continue;; esac
|
||||
if [[ "$trimmed" != *=* ]]; then
|
||||
echo "Invalid build arg: $trimmed" >&2
|
||||
exit 1
|
||||
fi
|
||||
BUILD_ARG_FLAGS+=(--build-arg "$arg")
|
||||
BUILD_ARG_FLAGS+=(--build-arg "$trimmed")
|
||||
|
||||
key="${arg%%=*}"
|
||||
val="${arg#*=}"
|
||||
key="${trimmed%%=*}"
|
||||
val="${trimmed#*=}"
|
||||
BUILD_ARGS_JSON=$(jq --arg k "$key" --arg v "$val" '. + {($k): $v}' <<<"$BUILD_ARGS_JSON")
|
||||
done
|
||||
done <<< "$BUILD_ARGS"
|
||||
fi
|
||||
|
||||
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 \
|
||||
postgres:16
|
||||
for i in {1..30}; do
|
||||
if docker exec "$container_name" pg_isready -U postgres > /dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
health="$(docker inspect --format '{{.State.Health.Status}}' "$container_name" 2>/dev/null || true)"
|
||||
case "$health" in
|
||||
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
|
||||
done
|
||||
if ! docker exec "$container_name" pg_isready -U postgres > /dev/null 2>&1; then
|
||||
echo "Postgres did not become ready in time." >&2
|
||||
if [ "${health:-}" != "healthy" ]; then
|
||||
echo "Postgres did not become healthy in time." >&2
|
||||
docker logs "$container_name" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user