{#- Context variables: bundle_name, app_name, catalog, warehouse_id, databricks_profile, workspace_host -#}
#!/usr/bin/env bash
# {{ demo_title }} — Full Deployment
# Deploys lakehouse (data gen, pipeline, ML) then companion app.
# Usage: ./scripts/deploy-all.sh [target]
#        SKIP_APP=true ./scripts/deploy-all.sh [target]
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

# Source environment
if [ -f "$SCRIPT_DIR/../.env" ]; then
  set -a; source "$SCRIPT_DIR/../.env"; set +a
fi

TARGET="${1:-dev}"

echo "========================================="
echo "Full Deploy: {{ bundle_name }} (${TARGET})"
echo "========================================="

# Step 1: Lakehouse
"$SCRIPT_DIR/deploy-lakehouse.sh" "$TARGET"

# Step 2: App (skip with SKIP_APP=true)
if [ "${SKIP_APP:-}" != "true" ]; then
  "$SCRIPT_DIR/deploy-app.sh" "$TARGET"
else
  echo "Skipping app deployment (SKIP_APP=true)"
fi

echo ""
echo "========================================="
echo "Full deployment complete!"
echo "========================================="
