Skip to content

fix: resolve TypeScript type error in tenantMiddleware #14

fix: resolve TypeScript type error in tenantMiddleware

fix: resolve TypeScript type error in tenantMiddleware #14

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# Code Quality & Testing
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: tnp_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
# Backend tests
- name: Backend - Install dependencies
run: cd backend && npm ci
- name: Backend - Run linter
run: cd backend && npm run lint 2>/dev/null || true
- name: Backend - Run tests
run: cd backend && npm test 2>/dev/null || true
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/tnp_test
# Frontend tests
- name: Frontend - Install dependencies
run: cd frontend && npm ci
- name: Frontend - Run linter
run: cd frontend && npm run lint 2>/dev/null || true
- name: Frontend - Build
run: cd frontend && npm run build
env:
VITE_API_BASE_URL: http://localhost:3001
# Docker Build & Push
docker-build:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build Backend
- name: Extract metadata (Backend)
id: meta-backend
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-backend
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and push Backend image
uses: docker/build-push-action@v5
with:
context: ./backend
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Build Frontend
- name: Extract metadata (Frontend)
id: meta-frontend
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and push Frontend image
uses: docker/build-push-action@v5
with:
context: ./frontend
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VITE_API_BASE_URL=http://localhost:3001
# Security Scanning
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner (Backend)
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: 'backend'
format: 'sarif'
output: 'trivy-backend-results.sarif'
- name: Run Trivy vulnerability scanner (Frontend)
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: 'frontend'
format: 'sarif'
output: 'trivy-frontend-results.sarif'
- name: Upload Trivy results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-*.sarif'
# Deploy to staging (optional - requires configuration)
deploy-staging:
needs: [test, docker-build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Deploy to Staging
run: |
echo "🚀 Deploying to staging environment..."
# Add your deployment script or commands here
# Example: kubectl apply -f k8s/staging/
# Or: docker-compose -f docker-compose.yml up -d
# Deploy to production (optional - requires configuration)
deploy-production:
needs: [test, docker-build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Deploy to Production
run: |
echo "🚀 Deploying to production environment..."
# Add your deployment script or commands here
# Example: kubectl apply -f k8s/production/
# Or: docker-compose -f docker-compose.prod.yml up -d