BuyingAgent/.gitea/workflows/deploy-prod.yml
Workflow config file is invalid. Please check your config file: yaml: line 29: could not find expected ':'
Lars 4b73e5fb53
All checks were successful
Test Suite / smoke-dev (push) Successful in 0s
Erlaube manuelles Ausloesen der Deploy-Workflows.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-03 10:54:08 +02:00

75 lines
2.6 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/lars/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
cat > .env <<'EOF'
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
EOF
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
docker compose build --no-cache api
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}) ==="