Files
WealthySmart/.github/workflows/deploy.yml
Carlos Escalante 881d879ed1
All checks were successful
Deploy to VPS / test (push) Successful in 1m51s
Deploy to VPS / deploy (push) Successful in 1m4s
Gate deploys on backend tests and frontend typecheck; record Phase 1
The new test job runs the 55-test pytest suite and pnpm typecheck
before the deploy job (needs: test) — a red suite now blocks prod.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 20:59:34 -06:00

74 lines
2.1 KiB
YAML

name: Deploy to VPS
on:
push:
branches: [main]
jobs:
test:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Backend tests
run: |
cd backend
python3 -m venv /tmp/test-venv
/tmp/test-venv/bin/pip install --quiet -r requirements.txt -r requirements-dev.txt
/tmp/test-venv/bin/python -m pytest tests/ -q
- name: Frontend typecheck
run: |
cd frontend
corepack enable
pnpm install --frozen-lockfile
pnpm typecheck
deploy:
runs-on: self-hosted
needs: test
steps:
- uses: actions/checkout@v4
- name: Write .env.prod
run: |
cat > .env.prod <<'ENVEOF'
POSTGRES_USER=${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB=${{ secrets.POSTGRES_DB }}
SECRET_KEY=${{ secrets.SECRET_KEY }}
ADMIN_USERNAME=${{ secrets.ADMIN_USERNAME }}
ADMIN_PASSWORD=${{ secrets.ADMIN_PASSWORD }}
LETSENCRYPT_EMAIL=${{ secrets.LETSENCRYPT_EMAIL }}
VAPID_PRIVATE_KEY=${{ secrets.VAPID_PRIVATE_KEY }}
VAPID_PUBLIC_KEY=${{ secrets.VAPID_PUBLIC_KEY }}
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
AGENT_MODEL=${{ secrets.AGENT_MODEL }}
ENVEOF
sed -i 's/^[[:space:]]*//' .env.prod
- name: Build and deploy
run: |
docker compose -f docker-compose.prod.yml --env-file .env.prod build
docker compose -f docker-compose.prod.yml --env-file .env.prod up -d --remove-orphans
- name: Wait for health
run: |
echo "Waiting for backend..."
for i in $(seq 1 30); do
if docker inspect wealthysmart-backend-prod --format '{{.State.Health.Status}}' 2>/dev/null | grep -q healthy; then
echo "Backend is healthy"
break
fi
sleep 2
done
- name: Prune old images
run: docker image prune -f
- name: Cleanup
if: always()
run: rm -f .env.prod