All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 33s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m9s
Build and Push Docker Images / Build Integrator (push) Successful in 56s
Build and Push Docker Images / Build Kestra Init (push) Successful in 32s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 0s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
60 lines
1.6 KiB
Bash
60 lines
1.6 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
KESTRA_URL="${KESTRA_URL:-http://kestra:8080}"
|
|
MAX_WAIT=120
|
|
|
|
# Basic auth — set KESTRA_USER / KESTRA_PASSWORD if authentication is enabled
|
|
AUTH=""
|
|
if [ -n "$KESTRA_USER" ] && [ -n "$KESTRA_PASSWORD" ]; then
|
|
AUTH="-u ${KESTRA_USER}:${KESTRA_PASSWORD}"
|
|
fi
|
|
|
|
echo "Waiting for Kestra API at ${KESTRA_URL}..."
|
|
elapsed=0
|
|
until curl -sf $AUTH "${KESTRA_URL}/api/v1/flows/search" > /dev/null 2>&1; do
|
|
if [ "$elapsed" -ge "$MAX_WAIT" ]; then
|
|
echo "ERROR: Kestra API not reachable after ${MAX_WAIT}s"
|
|
exit 1
|
|
fi
|
|
sleep 5
|
|
elapsed=$((elapsed + 5))
|
|
done
|
|
echo "Kestra API is ready."
|
|
|
|
echo "Importing flows..."
|
|
|
|
for f in /flows/*.yml; do
|
|
name="$(basename "$f")"
|
|
echo " -> $name"
|
|
|
|
http_code=$(curl -s $AUTH -o /tmp/kestra_resp -w "%{http_code}" \
|
|
-X POST "${KESTRA_URL}/api/v1/flows" \
|
|
-H "Content-Type: application/x-yaml" \
|
|
--data-binary "@${f}")
|
|
|
|
if [ "$http_code" = "200" ] || [ "$http_code" = "201" ]; then
|
|
echo " created"
|
|
elif [ "$http_code" = "409" ]; then
|
|
ns=$(grep '^namespace:' "$f" | awk '{print $2}')
|
|
id=$(grep '^id:' "$f" | awk '{print $2}')
|
|
http_code2=$(curl -s $AUTH -o /tmp/kestra_resp -w "%{http_code}" \
|
|
-X PUT "${KESTRA_URL}/api/v1/flows/${ns}/${id}" \
|
|
-H "Content-Type: application/x-yaml" \
|
|
--data-binary "@${f}")
|
|
if [ "$http_code2" = "200" ] || [ "$http_code2" = "201" ]; then
|
|
echo " updated"
|
|
else
|
|
echo " ERROR updating $name: HTTP $http_code2"
|
|
cat /tmp/kestra_resp; echo
|
|
exit 1
|
|
fi
|
|
else
|
|
echo " ERROR importing $name: HTTP $http_code"
|
|
cat /tmp/kestra_resp; echo
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
echo "All flows imported."
|