Skip to content

Add .vercel to .gitignore #13

Add .vercel to .gitignore

Add .vercel to .gitignore #13

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
types: [opened, synchronize, reopened]
env:
NODE_VERSION: "20"
jobs:
# ============================================
# QUALITY CHECKS & TESTING
# ============================================
quality-check:
name: Quality Check & Tests
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:7.0
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.runCommand(\"ping\").ok'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: |
backend/package-lock.json
frontend/package-lock.json
# Backend
- name: Install Backend Dependencies
working-directory: ./backend
run: npm ci
- name: Run Backend Linting
working-directory: ./backend
run: npm run lint --if-present
continue-on-error: true
- name: Run Backend Tests
working-directory: ./backend
run: npm run test:coverage
env:
NODE_ENV: test
MONGODB_URI: mongodb://localhost:27017/notes-app-test
JWT_SECRET: test-jwt-secret-for-ci-testing
JWT_EXPIRE: 7d
# Frontend
- name: Install Frontend Dependencies
working-directory: ./frontend
run: npm ci
- name: Run Frontend Linting
working-directory: ./frontend
run: npm run lint
continue-on-error: true
- name: Run Frontend Type Check
working-directory: ./frontend
run: npx tsc --noEmit
continue-on-error: true
- name: Run Frontend Tests
working-directory: ./frontend
run: npm run test:coverage
- name: Build Frontend
working-directory: ./frontend
run: npm run build
env:
VITE_API_URL: ${{ secrets.VITE_API_URL || 'https://your-backend.onrender.com/api' }}
# Upload coverage reports
- name: Upload Backend Coverage
uses: actions/upload-artifact@v4
with:
name: backend-coverage
path: backend/coverage/
retention-days: 7
- name: Upload Frontend Coverage
uses: actions/upload-artifact@v4
with:
name: frontend-coverage
path: frontend/coverage/
retention-days: 7
# ============================================
# SONARCLOUD ANALYSIS
# ============================================
sonarcloud:
name: SonarCloud Analysis
runs-on: ubuntu-latest
needs: quality-check
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Backend Coverage
uses: actions/download-artifact@v4
with:
name: backend-coverage
path: backend/coverage/
- name: Download Frontend Coverage
uses: actions/download-artifact@v4
with:
name: frontend-coverage
path: frontend/coverage/
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectKey=huzaifa-fullstack_scribo-notes-ai
-Dsonar.organization=huzaifa-fullstack
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.projectName=Scribo - AI-Powered Smart Notes
-Dsonar.sources=backend/src,frontend/src
-Dsonar.tests=backend/tests,frontend/src/tests
-Dsonar.exclusions=**/node_modules/**,**/dist/**,**/build/**,**/coverage/**
-Dsonar.javascript.lcov.reportPaths=backend/coverage/lcov.info,frontend/coverage/lcov.info
# ============================================
# SECURITY AUDIT
# ============================================
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Backend Security Audit
working-directory: ./backend
run: npm audit --audit-level=high
continue-on-error: true
- name: Frontend Security Audit
working-directory: ./frontend
run: npm audit --audit-level=high
continue-on-error: true
# ============================================
# DEPLOY BACKEND TO RENDER
# ============================================
deploy-backend:
name: Deploy Backend to Render
runs-on: ubuntu-latest
needs: [quality-check]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to Render
run: |
if [ -n "${{ secrets.RENDER_DEPLOY_HOOK_URL }}" ]; then
curl -X POST "${{ secrets.RENDER_DEPLOY_HOOK_URL }}"
echo "✅ Backend deployment triggered on Render"
else
echo "⚠️ RENDER_DEPLOY_HOOK_URL not configured. Skipping deployment."
echo "To enable automatic deployment, add RENDER_DEPLOY_HOOK_URL to your GitHub secrets."
fi
# ============================================
# DEPLOY FRONTEND TO VERCEL
# ============================================
deploy-frontend:
name: Deploy Frontend to Vercel
runs-on: ubuntu-latest
needs: [quality-check]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install Vercel CLI
run: npm install -g vercel@latest
- name: Install Frontend Dependencies
working-directory: ./frontend
run: npm ci
- name: Pull Vercel Environment
working-directory: ./frontend
run: |
if [ -n "${{ secrets.VERCEL_TOKEN }}" ]; then
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
else
echo "⚠️ VERCEL_TOKEN not configured"
fi
continue-on-error: true
- name: Build for Production
working-directory: ./frontend
run: |
if [ -n "${{ secrets.VERCEL_TOKEN }}" ]; then
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
else
npm run build
fi
env:
VITE_API_URL: ${{ secrets.VITE_API_URL }}
VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }}
- name: Deploy to Vercel
working-directory: ./frontend
run: |
if [ -n "${{ secrets.VERCEL_TOKEN }}" ]; then
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
echo "✅ Frontend deployed to Vercel"
else
echo "⚠️ VERCEL_TOKEN not configured. Skipping deployment."
echo "To enable automatic deployment, add these secrets:"
echo " - VERCEL_TOKEN"
echo " - VERCEL_ORG_ID"
echo " - VERCEL_PROJECT_ID"
fi
# ============================================
# NOTIFY ON COMPLETION
# ============================================
notify:
name: Notify Completion
runs-on: ubuntu-latest
needs: [quality-check, deploy-backend, deploy-frontend]
if: always() && github.ref == 'refs/heads/main'
steps:
- name: Deployment Summary
run: |
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Quality Check | ${{ needs.quality-check.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Backend Deployment | ${{ needs.deploy-backend.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Frontend Deployment | ${{ needs.deploy-frontend.result }} |" >> $GITHUB_STEP_SUMMARY