Files
EVOLV/scripts/deploy-flow.sh
znetsixe 6a6c04d34b Migrate to new Gitea instance (gitea.wbd-rd.nl)
- Update all submodule URLs from gitea.centraal.wbd-rd.nl to gitea.wbd-rd.nl
- Add settler as proper submodule in .gitmodules
- Add agent skills, function anchors, decisions, and improvements
- Add Docker configuration and scripts
- Add manuals and third_party docs
- Update .gitignore with secrets and build artifacts
- Remove stale .tgz build artifact

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 21:07:04 +01:00

80 lines
2.3 KiB
Bash

#!/bin/sh
# =============================================================
# EVOLV Flow Deployment Script
# Deploys a flow JSON file to the Node-RED instance
# Usage: deploy-flow.sh <flow-file.json>
# =============================================================
set -e
NODERED_URL="${NODERED_URL:-http://localhost:1880}"
FLOW_FILE="${1:-}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
if [ -z "$FLOW_FILE" ]; then
echo "Usage: deploy-flow.sh <flow-file.json>"
echo ""
echo "Examples:"
echo " deploy-flow.sh nodes/rotatingMachine/examples/basic.flow.json"
echo " deploy-flow.sh /data/evolv/nodes/reactor/examples/basic.flow.json"
exit 1
fi
# Resolve path inside container if relative
if [ ! -f "$FLOW_FILE" ] && [ -f "/data/evolv/$FLOW_FILE" ]; then
FLOW_FILE="/data/evolv/$FLOW_FILE"
fi
if [ ! -f "$FLOW_FILE" ]; then
printf "${RED}ERROR${NC}: Flow file not found: %s\n" "$FLOW_FILE"
exit 1
fi
echo "=============================================="
echo " EVOLV Flow Deployment"
echo " File: $FLOW_FILE"
echo " Target: $NODERED_URL"
echo "=============================================="
echo ""
# ---------------------------------------------------------
# Verify Node-RED is running
# ---------------------------------------------------------
if ! curl -sf "$NODERED_URL/nodes" > /dev/null 2>&1; then
printf "${RED}ERROR${NC}: Node-RED not reachable at %s\n" "$NODERED_URL"
echo "Start it with: docker compose up -d"
exit 1
fi
# ---------------------------------------------------------
# Deploy flow
# ---------------------------------------------------------
printf "Deploying flow... "
RESPONSE=$(curl -s -w "\n%{http_code}" \
-X POST \
-H "Content-Type: application/json" \
-H "Node-RED-Deployment-Type: full" \
-d @"$FLOW_FILE" \
"$NODERED_URL/flows" 2>&1)
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" = "204" ] || [ "$HTTP_CODE" = "200" ]; then
printf "${GREEN}SUCCESS${NC} (HTTP %s)\n" "$HTTP_CODE"
echo ""
echo "Flow deployed. Open Node-RED editor at: $NODERED_URL"
else
printf "${RED}FAILED${NC} (HTTP %s)\n" "$HTTP_CODE"
if [ -n "$BODY" ]; then
echo "Response:"
echo "$BODY" | sed 's/^/ /'
fi
exit 1
fi