warmbox/scripts/deploy.sh
Jonny Nguyen ed3ec86025 Add Woodpecker CI/CD pipeline configuration and new chart components
Introduce a Woodpecker CI/CD pipeline in `.woodpecker.yml` for automated deployment on pushes to the main branch. Add new components for visualizing campaign performance, including `DailyPerformanceChart`, `InboxPlacementChart`, and `InboxVsSpamChart`, to enhance the Campaign Detail page. Update `WarmupPlanChart` to include additional metrics and improve tooltip information. Enhance utility functions for chart data formatting and daily statistics mapping.
2026-06-26 14:23:18 -07:00

48 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Production deploy — run on the server in the git checkout (e.g. /srv/docker-configs/warmbox).
# Used by Woodpecker CI and manual deploys.
set -euo pipefail
DEPLOY_DIR="${DEPLOY_DIR:-$(cd "$(dirname "$0")/.." && pwd)}"
BRANCH="${DEPLOY_BRANCH:-main}"
cd "$DEPLOY_DIR"
echo "==> Deploying Warmbox from ${DEPLOY_DIR} (branch ${BRANCH})"
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "ERROR: ${DEPLOY_DIR} is not a git repository"
exit 1
fi
git fetch origin "$BRANCH"
git reset --hard "origin/${BRANCH}"
if [[ ! -f .env ]]; then
echo "ERROR: .env missing in ${DEPLOY_DIR}. Create it from .env.example before deploying."
exit 1
fi
echo "==> Stopping containers..."
docker compose down
echo "==> Building and starting..."
docker compose up -d --build
echo "==> Waiting for container health..."
for i in $(seq 1 30); do
if docker compose exec -T warmbox node -e \
"fetch('http://127.0.0.1:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" \
>/dev/null 2>&1; then
echo "==> Health check passed"
docker compose ps
echo "==> Deploy complete"
exit 0
fi
sleep 2
done
echo "==> Health check failed"
docker compose ps
docker compose logs --tail=80 warmbox
exit 1