BuyingAgent/.gitea/workflows/deploy-prod.yml
Lars 68a8e3d945
Some checks failed
Deploy Development / deploy (push) Successful in 2m6s
Test Suite / pytest-backend (push) Failing after 14s
Test Suite / smoke-dev (push) Successful in 1s
Test Suite / frontend-checks (push) Successful in 28s
Uebernimm Enum-Listen und Filtergruppen in die Taxonomie, speichere Suchtreffer als Kandidaten und lasse CI das vorhandene API-Image nutzen.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-04 15:12:51 +02:00

80 lines
3.0 KiB
YAML

name: Deploy Production
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy BuyingAgent to production
run: |
set -e
echo "=== Deploying BuyingAgent to PRODUCTION ==="
REPO="http://192.168.2.144:3000/Lars/BuyingAgent.git"
TARGET="$HOME/docker/buyingagent"
mkdir -p "$TARGET"
cd "$TARGET"
if [ ! -d .git ]; then
git clone -b main "$REPO" .
else
git fetch origin main
git checkout main
git reset --hard origin/main
fi
if [ ! -f .env ]; then
printf '%s\n' \
'DB_NAME=buyingagent' \
'DB_USER=buyingagent' \
'DB_PASSWORD=change_me' \
'ENVIRONMENT=production' \
'BUYING_AGENT_API_BIND=0.0.0.0' \
'BUYING_AGENT_API_PORT=8006' > .env
echo "created production .env — set a unique DB_PASSWORD after first start"
fi
if grep -q '^BUYING_AGENT_API_BIND=' .env; then
sed -i 's/^BUYING_AGENT_API_BIND=.*/BUYING_AGENT_API_BIND=0.0.0.0/' .env
else
echo 'BUYING_AGENT_API_BIND=0.0.0.0' >> .env
fi
if grep -q '^BUYING_AGENT_API_PORT=' .env; then
sed -i 's/^BUYING_AGENT_API_PORT=.*/BUYING_AGENT_API_PORT=8006/' .env
else
echo 'BUYING_AGENT_API_PORT=8006' >> .env
fi
export ENGINE_BUILD BUYING_AGENT_API_BIND BUYING_AGENT_API_PORT
ENGINE_BUILD="$(git rev-parse --short HEAD)"
BUYING_AGENT_API_BIND=0.0.0.0
BUYING_AGENT_API_PORT=8006
if ! grep -q '^CORS_ALLOWED_ORIGINS=' .env; then
echo 'CORS_ALLOWED_ORIGINS=http://192.168.2.49:4173,http://localhost:4173' >> .env
fi
if ! grep -q '^BUYING_AGENT_FRONTEND_PORT=' .env; then
echo 'BUYING_AGENT_FRONTEND_PORT=4173' >> .env
fi
COMPOSE_BAKE=0 docker compose build --pull=false api frontend
if ! ENGINE_BUILD="$ENGINE_BUILD" \
BUYING_AGENT_API_BIND="$BUYING_AGENT_API_BIND" \
BUYING_AGENT_API_PORT="$BUYING_AGENT_API_PORT" \
docker compose up -d --wait; then
echo "compose up --wait failed — api logs:"
docker compose logs api --tail 150 || true
docker compose ps || true
exit 1
fi
if ! curl -sf http://localhost:8006/health/live; then
echo "PROD /health/live not reachable — api logs:"
docker compose logs api --tail 150 || true
exit 1
fi
echo "PROD /health/live OK"
if ! curl -sf http://localhost:8006/health/ready; then
echo "PROD /health/ready failed — api logs:"
docker compose logs api --tail 150 || true
exit 1
fi
echo "PROD /health/ready OK"
echo "=== BuyingAgent PROD deploy complete (${ENGINE_BUILD}) ==="