-
Notifications
You must be signed in to change notification settings - Fork 1
164 lines (137 loc) · 4.5 KB
/
Copy pathdeploy.yml
File metadata and controls
164 lines (137 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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