Skip to content

Logging service has been implemented and is saving to prisma database #72

Logging service has been implemented and is saving to prisma database

Logging service has been implemented and is saving to prisma database #72

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
# ─── Step 1: Run Tests ───────────────────────────────────
test:
name: Run Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: petad
POSTGRES_PASSWORD: petadpassword
POSTGRES_DB: petad_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgresql://petad:petadpassword@localhost:5432/petad_db
REDIS_URL: redis://localhost:6379
JWT_SECRET: test-super-secret-jwt-key-for-ci-pipeline
JWT_EXPIRATION: 7d
PORT: 3000
NODE_ENV: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Generate Prisma Client
run: npx prisma generate
- name: Run database migrations
run: npx prisma migrate deploy
- name: Run unit tests
run: npm test
- name: Run e2e tests
run: npm run test:e2e
# ─── Step 2: Build Check ─────────────────────────────────
build:
name: Build Check
runs-on: ubuntu-latest
needs: test # Only runs if tests pass
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Generate Prisma Client
run: npx prisma generate
- name: Build application
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 1
# ─── Step 3: Deploy (only on push to main) ───────────────
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build # Only runs if build passes
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
# ── Replace this step with your actual deploy command ──
# Example options shown below — uncomment the one you use:
# Option A: Railway
# - name: Deploy to Railway
# run: npx @railway/cli deploy
# env:
# RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
# Option B: Render (via deploy hook)
# - name: Deploy to Render
# run: curl -X POST ${{ secrets.RENDER_DEPLOY_HOOK }}
# Option C: Docker Hub + SSH to your server
# - name: Build and push Docker image
# run: |
# echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
# docker build -t yourname/petad-backend:latest .
# docker push yourname/petad-backend:latest
- name: Deploy placeholder
run: echo "✅ Tests and build passed. Add your deploy command above."