First start n8n seed & activate
Run Tests on Branches / Detect Changes (push) Successful in 14s
Run Tests on Branches / Backend Tests (push) Has been skipped
Run Tests on Branches / Frontend Mobile Tests (push) Has been skipped
Run Tests on Branches / Frontend Tests (push) Has been skipped
Run Tests on Branches / Parapharmacy API Tests (push) Successful in 1m35s
Run Tests on Branches / PIP Platform Tests (push) Has been skipped
Run Tests on Branches / Detect Changes (push) Successful in 14s
Run Tests on Branches / Backend Tests (push) Has been skipped
Run Tests on Branches / Frontend Mobile Tests (push) Has been skipped
Run Tests on Branches / Frontend Tests (push) Has been skipped
Run Tests on Branches / Parapharmacy API Tests (push) Successful in 1m35s
Run Tests on Branches / PIP Platform Tests (push) Has been skipped
This commit is contained in:
+35
-5
@@ -1,22 +1,52 @@
|
||||
#!/bin/sh
|
||||
# One-shot init: import workflows into n8n on first deploy.
|
||||
# Skips if already imported (flag file in shared volume).
|
||||
# One-shot init: import workflows, activate them, and seed the DB.
|
||||
# Skips if already done (flag file in shared n8n_data volume).
|
||||
set -e
|
||||
|
||||
FLAG="/home/node/.n8n/.workflows-imported"
|
||||
|
||||
if [ -f "$FLAG" ]; then
|
||||
echo "[n8n-init] Workflows already imported, skipping."
|
||||
echo "[n8n-init] Already initialized, skipping."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ── 1. Wait for n8n ──────────────────────────────────────────────────
|
||||
echo "[n8n-init] Waiting for n8n to be ready..."
|
||||
until wget -qO /dev/null http://n8n:5678/healthz 2>/dev/null; do
|
||||
sleep 2
|
||||
done
|
||||
echo "[n8n-init] n8n is up."
|
||||
|
||||
echo "[n8n-init] Importing workflows from /home/node/workflows/..."
|
||||
# ── 2. Import workflows ──────────────────────────────────────────────
|
||||
echo "[n8n-init] Importing workflows..."
|
||||
n8n import:workflow --separate --input=/home/node/workflows/
|
||||
echo "[n8n-init] Workflows imported."
|
||||
|
||||
# ── 3. Activate workflows via n8n API (Node.js) ─────────────────────
|
||||
if [ -f /home/node/activate-workflows.js ]; then
|
||||
echo "[n8n-init] Activating workflows via n8n API..."
|
||||
node /home/node/activate-workflows.js "${N8N_OWNER_EMAIL}" "${N8N_OWNER_PASSWORD}" || \
|
||||
echo "[n8n-init] WARNING: Workflow activation failed. Activate manually via n8n UI."
|
||||
else
|
||||
echo "[n8n-init] WARNING: activate-workflows.js not found, skipping activation."
|
||||
fi
|
||||
|
||||
# ── 4. Seed parapharmacy DB ──────────────────────────────────────────
|
||||
echo "[n8n-init] Waiting for parapharmacy-api to be ready..."
|
||||
until wget -qO /dev/null http://parapharmacy-api:3002/api/health 2>/dev/null; do
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [ -f /home/node/seed.json ]; then
|
||||
echo "[n8n-init] Seeding parapharmacy products..."
|
||||
SEED_RESP=$(wget -qO- --post-file=/home/node/seed.json \
|
||||
--header="Content-Type: application/json" \
|
||||
http://parapharmacy-api:3002/api/products/bulk 2>&1)
|
||||
echo "[n8n-init] Seed result: $SEED_RESP"
|
||||
else
|
||||
echo "[n8n-init] WARNING: seed.json not found, skipping seed."
|
||||
fi
|
||||
|
||||
# ── Done ─────────────────────────────────────────────────────────────
|
||||
touch "$FLAG"
|
||||
echo "[n8n-init] Import complete."
|
||||
echo "[n8n-init] Initialization complete."
|
||||
|
||||
Reference in New Issue
Block a user