All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 32s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m4s
Build and Push Docker Images / Build Integrator (push) Successful in 56s
Build and Push Docker Images / Build Kestra Init (push) Successful in 31s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 0s
- POST /api/v1/flows with Content-Type: application/x-yaml (not the
ZIP-based /import endpoint)
- On 409 (already exists), fall back to PUT /api/v1/flows/{ns}/{id}
so redeployment updates existing flows rather than failing
- Print HTTP response body on error for easier debugging
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.2 KiB
Bash
42 lines
1.2 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
KESTRA_URL="${KESTRA_URL:-http://kestra:8080}"
|
|
|
|
echo "Importing flows into Kestra at ${KESTRA_URL}..."
|
|
|
|
for f in /flows/*.yml; do
|
|
name="$(basename "$f")"
|
|
echo " -> $name"
|
|
|
|
http_code=$(curl -s -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
|
|
# Flow already exists — update it via PUT /api/v1/flows/{namespace}/{id}
|
|
ns=$(grep '^namespace:' "$f" | awk '{print $2}')
|
|
id=$(grep '^id:' "$f" | awk '{print $2}')
|
|
http_code2=$(curl -s -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."
|