fix: launch docker compose on first run too
CI / test-and-package (push) Successful in 31s

This commit is contained in:
agentbox
2026-07-31 22:45:56 +00:00
parent 0a7fdd6a49
commit 26a830c39f
+14 -11
View File
@@ -47,27 +47,30 @@ while true; do
echo "[$(date -Iseconds)] New commits detected! Updating..." echo "[$(date -Iseconds)] New commits detected! Updating..."
echo " Previous: $LAST_HASH" echo " Previous: $LAST_HASH"
echo " Current: $REMOTE_HASH" echo " Current: $REMOTE_HASH"
git pull origin main 2>&1 || { git pull origin main 2>&1 || {
echo "[$(date -Iseconds)] ERROR: git pull failed, retrying in 20s..." echo "[$(date -Iseconds)] ERROR: git pull failed, retrying in 20s..."
LAST_HASH="" LAST_HASH=""
sleep 20 sleep 20
continue continue
} }
echo "[$(date -Iseconds)] Bringing containers down..." echo "[$(date -Iseconds)] Bringing containers down..."
docker compose -f "$COMPOSE_FILE" down 2>&1 docker compose -f "$COMPOSE_FILE" down 2>&1
echo "[$(date -Iseconds)] Building images..."
docker compose -f "$COMPOSE_FILE" build 2>&1
echo "[$(date -Iseconds)] Starting containers..."
docker compose -f "$COMPOSE_FILE" up -d 2>&1
echo "[$(date -Iseconds)] Update complete."
else else
echo "[$(date -Iseconds)] Initial state recorded: $REMOTE_HASH" echo "[$(date -Iseconds)] First run — pulling and launching containers..."
git pull origin main 2>&1 || {
echo "[$(date -Iseconds)] ERROR: git pull failed, retrying in 20s..."
sleep 20
continue
}
fi fi
echo "[$(date -Iseconds)] Building images..."
docker compose -f "$COMPOSE_FILE" build 2>&1
echo "[$(date -Iseconds)] Starting containers..."
docker compose -f "$COMPOSE_FILE" up -d 2>&1
echo "[$(date -Iseconds)] Update complete."
LAST_HASH="$REMOTE_HASH" LAST_HASH="$REMOTE_HASH"
else else
echo "[$(date -Iseconds)] No changes." echo "[$(date -Iseconds)] No changes."