Skip to content

README.md

README.md #17

Workflow file for this run

name: Deploy to Render and Vercel
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
env:
NODE_VERSION: '20'
jobs:
test:
name: Test Application
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 }}
cache: 'npm'
cache-dependency-path: |
backend/package-lock.json
frontend/package-lock.json
- name: Install backend dependencies
run: |
cd backend
npm ci
- name: Install frontend dependencies
run: |
cd frontend
npm ci
- name: Setup test environment
run: |
cd backend
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env
echo "PORT=4000" >> .env
echo "NODE_ENV=test" >> .env
echo "FRONTEND_URL=http://localhost:3000" >> .env
- name: Run backend build
run: |
cd backend
npm run build
- name: Run frontend build
env:
REACT_APP_API_URL: http://localhost:4000
run: |
cd frontend
npm run build
- name: Run backend tests
run: |
cd backend
npm test
# - name: Run frontend tests
# run: |
# cd frontend
# CI=true npm test -- --coverage --watchAll=false
deploy-backend:
name: Deploy Backend to Render
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to Render
uses: johnbeynon/render-deploy-action@v0.0.8
with:
service-id: ${{ secrets.RENDER_SERVICE_ID }}
api-key: ${{ secrets.RENDER_API_KEY }}
- name: Wait for deployment
run: |
echo "⏳ Waiting for Render deployment to complete..."
sleep 60
echo "✅ Backend deployment initiated"
deploy-frontend:
name: Deploy Frontend to Vercel
needs: [test, deploy-backend]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
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 --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
working-directory: frontend
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
working-directory: frontend
env:
REACT_APP_API_URL: ${{ secrets.RENDER_BACKEND_URL }}
REACT_APP_SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
REACT_APP_SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
working-directory: frontend
notify:
name: Notify Deployment Status
needs: [deploy-backend, deploy-frontend]
runs-on: ubuntu-latest
if: always() && github.ref == 'refs/heads/main'
steps:
- name: Deployment Success
if: needs.deploy-backend.result == 'success' && needs.deploy-frontend.result == 'success'
run: |
echo "🎉 Deployment successful!"
echo "Backend: ${{ secrets.RENDER_BACKEND_URL }}"
echo "Frontend: ${{ secrets.VERCEL_FRONTEND_URL }}"
- name: Deployment Failed
if: needs.deploy-backend.result == 'failure' || needs.deploy-frontend.result == 'failure'
run: |
echo "❌ Deployment failed!"
echo "Check the logs above for details."
exit 1
# Required GitHub Secrets for Render + Vercel:
# Database & Authentication:
# - DATABASE_URL: Complete PostgreSQL connection string
# - SUPABASE_URL: https://your-project-id.supabase.co
# - SUPABASE_ANON_KEY: Your Supabase anon/public key
# - SUPABASE_SERVICE_ROLE_KEY: Your Supabase service role key
# - JWT_SECRET: Your JWT secret key
#
# Render (Backend):
# - RENDER_API_KEY: Your Render API key
# - RENDER_SERVICE_ID: Your Render service ID
# - RENDER_BACKEND_URL: https://your-backend-app.onrender.com
#
# Vercel (Frontend):
# - VERCEL_TOKEN: Your Vercel API token
# - VERCEL_FRONTEND_URL: https://your-frontend-app.vercel.app