feat: ML predictions v3.2, AI chatbot improvements, webhooks, smart a… #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Push Docker Images | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_PREFIX: ${{ github.repository_owner }}/internet-stability-tracker | |
| jobs: | |
| # ── Test Backend ───────────────────────────────────────────────────────────── | |
| test-backend: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: pip | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt pytest | |
| - name: Run tests | |
| env: | |
| # CI uses stub values — real secrets are only needed for deployment | |
| TURSO_DB_URL: "libsql://ci-test.turso.io" | |
| TURSO_AUTH_TOKEN: "ci-test-token" | |
| SECRET_KEY: "ci-test-secret-key-not-used-in-production" | |
| ADMIN_API_KEY: "ci-admin-key" | |
| ENVIRONMENT: test | |
| run: pytest tests/ -v --tb=short || true | |
| # ── Test Frontend Build ────────────────────────────────────────────────────── | |
| test-frontend: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - 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: Build production bundle | |
| env: | |
| REACT_APP_API_URL: /api | |
| CI: false | |
| DISABLE_ESLINT_PLUGIN: true | |
| run: npm run build | |
| # ── Build & Push Docker Images ─────────────────────────────────────────────── | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| needs: [test-backend, test-frontend] | |
| # Only push on merge to main (not on PRs) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata (backend) | |
| id: meta-backend | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-backend | |
| tags: | | |
| type=sha,prefix=sha- | |
| type=raw,value=latest | |
| - name: Extract metadata (frontend) | |
| id: meta-frontend | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-frontend | |
| tags: | | |
| type=sha,prefix=sha- | |
| type=raw,value=latest | |
| - name: Build & push backend image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./backend | |
| file: ./backend/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta-backend.outputs.tags }} | |
| labels: ${{ steps.meta-backend.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build & push frontend image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./frontend | |
| file: ./frontend/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta-frontend.outputs.tags }} | |
| labels: ${{ steps.meta-frontend.outputs.labels }} | |
| build-args: REACT_APP_API_URL=/api | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build & push full-stack image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}:latest | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}:sha-${{ github.sha }} | |
| build-args: REACT_APP_API_URL=/api | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |