-
Notifications
You must be signed in to change notification settings - Fork 1
112 lines (96 loc) · 3.75 KB
/
Copy pathdeploy.yml
File metadata and controls
112 lines (96 loc) · 3.75 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
name: Deploy SmartProBono
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
name: Deploy Frontend and Backend
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Debug - List all files in frontend directory
run: |
ls -la frontend/
cat frontend/package.json | grep -A 5 dependencies
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'backend/requirements.txt'
- name: Install frontend dependencies
run: |
cd frontend
npm ci || npm install
- name: Debug environment variables
run: |
echo "Checking environment variables"
echo "NODE_ENV: $NODE_ENV"
echo "REACT_APP_API_URL: $REACT_APP_API_URL"
- name: Build frontend
env:
NODE_ENV: production
REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL || 'https://smartprobono-api.onrender.com' }}
REACT_APP_WS_URL: ${{ secrets.REACT_APP_WS_URL || 'wss://smartprobono-api.onrender.com' }}
run: |
cd frontend
DISABLE_ESLINT_PLUGIN=true npm run build
- name: Install backend dependencies
run: |
cd backend
pip install -r requirements.txt
- name: Setup Cloudinary
run: |
cd backend
python scripts/setup_cloudinary.py --test-only
env:
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
CLOUDINARY_API_KEY: ${{ secrets.CLOUDINARY_API_KEY }}
CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET }}
- name: Deploy to Render
env:
RENDER_TOKEN: ${{ secrets.RENDER_API_KEY }}
run: |
# Create environment variables payload for backend
cat > env_vars.json << EOF
{
"envVars": [
{"key": "CLOUDINARY_CLOUD_NAME", "value": "${{ secrets.CLOUDINARY_CLOUD_NAME }}"},
{"key": "CLOUDINARY_API_KEY", "value": "${{ secrets.CLOUDINARY_API_KEY }}"},
{"key": "CLOUDINARY_API_SECRET", "value": "${{ secrets.CLOUDINARY_API_SECRET }}"},
{"key": "OPENAI_API_KEY", "value": "${{ secrets.OPENAI_API_KEY }}"},
{"key": "HUGGINGFACE_API_KEY", "value": "${{ secrets.HUGGINGFACE_API_KEY }}"}
]
}
EOF
# Update environment variables for backend service
curl -X PATCH \
-H "Authorization: Bearer $RENDER_TOKEN" \
-H "Content-Type: application/json" \
-d @env_vars.json \
"https://api.render.com/v1/services/${{ secrets.RENDER_BACKEND_ID }}/env-vars"
# Deploy backend
curl -X POST \
-H "Authorization: Bearer $RENDER_TOKEN" \
-H "Content-Type: application/json" \
"https://api.render.com/v1/services/${{ secrets.RENDER_BACKEND_ID }}/deploys"
# Deploy frontend
curl -X POST \
-H "Authorization: Bearer $RENDER_TOKEN" \
-H "Content-Type: application/json" \
"https://api.render.com/v1/services/${{ secrets.RENDER_FRONTEND_ID }}/deploys"
- name: Notify deployment status
if: always()
run: |
if [ "${{ job.status }}" = "success" ]; then
echo "Deployment completed successfully!"
else
echo "Deployment failed! Check the logs for more information."
fi