-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (150 loc) · 4.85 KB
/
Copy pathci-cd.yml
File metadata and controls
175 lines (150 loc) · 4.85 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
165
166
167
168
169
170
171
172
173
174
175
name: CI-CD
on:
push:
branches:
- main
- dev
- development
pull_request:
branches:
- main
- dev
- development
jobs:
checks:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: app/package-lock.json
- name: Build frontend
working-directory: app
run: |
npm ci
npm run build
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install backend dependencies
working-directory: api
run: |
python -m pip install --no-input --upgrade pip
pip install --no-input -r requirements.txt
- name: Run backend tests
working-directory: api
run: python -m pytest -q
deploy-development:
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/development'
needs: checks
runs-on: ubuntu-latest
timeout-minutes: 20
environment:
name: development
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js for Vercel CLI
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Vercel CLI
run: npm install -g vercel@25.1.0
- name: Link Vercel project
working-directory: app
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_SCOPE: ${{ secrets.VERCEL_SCOPE }}
run: |
vercel link \
--project app \
--scope "$VERCEL_SCOPE" \
--confirm \
--token "$VERCEL_TOKEN"
- name: Write .env.production
working-directory: app
run: echo "NEXT_PUBLIC_API_BASE=${{ secrets.NEXT_PUBLIC_API_BASE_DEV }}" > .env.production
- name: Deploy frontend (Vercel)
working-directory: app
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_SCOPE: ${{ secrets.VERCEL_SCOPE }}
run: |
attempt=1
max_attempts=3
while :; do
if vercel deploy --confirm --token "$VERCEL_TOKEN" --scope "$VERCEL_SCOPE"; then
break
fi
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Vercel deploy failed after ${max_attempts} attempt(s)."
exit 1
fi
sleep_seconds=$((attempt * 10))
echo "Vercel deploy failed. Retry ${attempt}/${max_attempts} in ${sleep_seconds}s..."
sleep "$sleep_seconds"
attempt=$((attempt + 1))
done
# Railway: auto-deploys from dev branch via GitHub integration.
# No CLI or deploy hook needed — Railway watches this branch
# and waits for CI checks to pass ("Check Suites" enabled).
deploy-production:
if: github.ref == 'refs/heads/main'
needs: checks
runs-on: ubuntu-latest
timeout-minutes: 20
environment:
name: production
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js for Vercel CLI
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Vercel CLI
run: npm install -g vercel@25.1.0
- name: Link Vercel project
working-directory: app
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_SCOPE: ${{ secrets.VERCEL_SCOPE }}
run: |
vercel link \
--project app \
--scope "$VERCEL_SCOPE" \
--confirm \
--token "$VERCEL_TOKEN"
- name: Write .env.production
working-directory: app
run: echo "NEXT_PUBLIC_API_BASE=${{ secrets.NEXT_PUBLIC_API_BASE_PROD }}" > .env.production
- name: Deploy frontend (Vercel)
working-directory: app
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_SCOPE: ${{ secrets.VERCEL_SCOPE }}
run: |
attempt=1
max_attempts=3
while :; do
if vercel deploy --prod --confirm --token "$VERCEL_TOKEN" --scope "$VERCEL_SCOPE"; then
break
fi
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Vercel deploy failed after ${max_attempts} attempt(s)."
exit 1
fi
sleep_seconds=$((attempt * 10))
echo "Vercel deploy failed. Retry ${attempt}/${max_attempts} in ${sleep_seconds}s..."
sleep "$sleep_seconds"
attempt=$((attempt + 1))
done
# Railway: auto-deploys from main branch via GitHub integration.
# No CLI or deploy hook needed — Railway watches this branch
# and waits for CI checks to pass ("Check Suites" enabled).