Skip to content

Add live data indicators to frontend #9

Add live data indicators to frontend

Add live data indicators to frontend #9

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov ruff
- name: Lint with ruff
run: |
ruff check .
ruff format --check .
- name: Create test database
run: python create_canonical_db.py
- name: Run tests
run: |
pytest tests/ -v --cov=. --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
build-backend:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-backend
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: api/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-frontend:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: frontend/nextjs/package-lock.json
- name: Install dependencies
working-directory: frontend/nextjs
run: npm ci
- name: Build Next.js app
working-directory: frontend/nextjs
run: npm run build
env:
NEXT_PUBLIC_API_URL: ${{ secrets.API_URL || 'http://localhost:8000' }}
deploy-backend:
if: github.ref == 'refs/heads/main'
needs: [test, build-backend]
runs-on: ubuntu-latest
steps:
- name: Deploy to Render
if: ${{ env.RENDER_API_KEY != '' }}
run: |
curl -X POST "https://api.render.com/v1/services/${{ secrets.RENDER_SERVICE_ID }}/deploys" \
-H "Authorization: Bearer ${{ secrets.RENDER_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{"clearCache": false}'
env:
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }}
deploy-frontend:
if: github.ref == 'refs/heads/main'
needs: [test, build-frontend]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy to Vercel
if: ${{ env.VERCEL_TOKEN != '' }}
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
working-directory: frontend/nextjs
vercel-args: '--prod'
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}