name: CI on: push: branches: - main pull_request: jobs: python-quality: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt -r requirements-dev.txt - name: Ruff run: python -m ruff check . - name: Pytest run: python -m pytest frontend-quality: runs-on: ubuntu-latest defaults: run: working-directory: frontend steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Node uses: actions/setup-node@v4 with: node-version: "20" cache: "npm" cache-dependency-path: frontend/package-lock.json - name: Install dependencies run: npm ci - name: Business state tests run: npm run test:business - name: Build run: npm run build - name: Upload frontend build artifact uses: actions/upload-artifact@v4 with: name: frontend-next path: | frontend/.next frontend/package.json frontend/package-lock.json frontend/next.config.mjs frontend/public !frontend/.next/cache deploy: needs: [python-quality, frontend-quality] if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Download frontend build artifact uses: actions/download-artifact@v4 with: name: frontend-next path: frontend - name: Deploy to VPS run: | mkdir -p ~/.ssh echo "${{ secrets.VPS_SSH_KEY }}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa scp -o StrictHostKeyChecking=accept-new -r frontend/.next frontend/package.json frontend/package-lock.json frontend/next.config.mjs ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }}:/root/PolyWeather/frontend/ ssh -o StrictHostKeyChecking=accept-new ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} " cd /root/PolyWeather git fetch origin main && git reset --hard origin/main docker compose down docker compose up -d --build sleep 10 curl -s http://localhost:8000/healthz "