-
Notifications
You must be signed in to change notification settings - Fork 0
294 lines (285 loc) · 13.7 KB
/
worker-ci.yaml
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: Worker CI
on:
push:
branches:
- main
- dev
concurrency:
group: ${{ github.ref }}-worker
cancel-in-progress: true
env:
IMAGE: ${{ github.event.repository.name }}-worker-${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
REGISTRY: ${{ vars.REGISTRY }}
jobs:
build-worker:
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, '~worker') || contains(github.event.head_commit.message, '~deploy') || contains(github.event.head_commit.message, '~sitemaps') || contains(github.event.head_commit.message, '~topics') || contains(github.event.head_commit.message, '~caches') || contains(github.event.head_commit.message, '~notifs') }}
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
steps:
- name: Print Job Description
run: |
echo building \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Build
run: |
docker build . --file Dockerfile.worker --tag $IMAGE:latest
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to doctl
run: doctl registry login --expiry-seconds 600
- name: Tag Docker Image
run: docker tag $IMAGE:latest $REGISTRY/$IMAGE:latest
- name: Push Docker Image
run: docker push $REGISTRY/$IMAGE:latest
deploy-worker-sitemaps:
needs: build-worker
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, '~worker') || contains(github.event.head_commit.message, '~sitemaps') }}
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
env:
BASE_DOMAIN: ${{ vars.BASE_DOMAIN }}
CHROMIUM_EXECUTABLE_PATH: ${{ vars.CHROMIUM_EXECUTABLE_PATH }}
CONTAINER_NAME: ${{ github.event.repository.name }}-worker-${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}-sitemaps
DEEPAI_API_KEY: ${{ secrets.DEEPAI_API_KEY }}
ENABLED_FEATURES: ${{ vars.ENABLED_FEATURES }}
ERROR_REPORTING: $${{ vars.ERROR_REPORTING }}
FIREBASE_CREDENTIALS: ${{ secrets.FIREBASE_CREDENTIALS }}
K8S_NAMESPACE: ${{ secrets.K8S_NAMESPACE }}
K8S_MEMORY_REQUESTS: ${{ vars.K8S_MEMORY_REQUESTS }}
K8S_CPU_REQUESTS: ${{ vars.K8S_CPU_REQUESTS }}
K8S_MEMORY_LIMITS: ${{ vars.K8S_MEMORY_LIMITS }}
K8S_CPU_LIMITS: ${{ vars.K8S_CPU_LIMITS }}
K8S_REPLICA_COUNT_WORKER: ${{ vars.K8S_REPLICA_COUNT_WORKER_SITEMAPS || 1 }}
MAIL_HOST: ${{ vars.MAIL_HOST }}
MAIL_PASS: ${{ secrets.MAIL_PASS }}
MAIL_PORT: ${{ vars.MAIL_PORT }}
MAIL_REPLY_TO: ${{ vars.MAIL_REPLY_TO }}
MAIL_USER: ${{ secrets.MAIL_USER }}
MAX_OPENAI_TOKEN_COUNT: ${{ vars.MAX_OPENAI_TOKEN_COUNT }}
OLD_NEWS_THRESHOLD: ${{ vars.OLD_NEWS_THRESHOLD }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PUBLISHER_FETCH_INTERVAL: ${{ vars.PUBLISHER_FETCH_INTERVAL }}
PUBLISHER_FETCH_LIMIT: ${{ vars.PUBLISHER_FETCH_LIMIT }}
PUBLISHER_MAX_ATTEMPT_LIMIT: ${{ vars.PUBLISHER_MAX_ATTEMPT_LIMIT }}
PG_CONNECTION_STRING: ${{ secrets.PG_CONNECTION_STRING }}
PLAY_HT_SECRET_KEY: ${{ secrets.PLAY_HT_SECRET_KEY }}
PLAY_HT_USER_ID: ${{ secrets.PLAY_HT_USER_ID }}
PORT: ${{ vars.PORT }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_KEY: ${{ secrets.S3_KEY }}
S3_SECRET: ${{ secrets.S3_SECRET }}
WORKER_RETRY_EXPRS: ${{ vars.WORKER_RETRY_EXPRS }}
WORKER_QUEUE: sitemaps
steps:
- name: Print Job Description
run: |
echo deploying \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Add kubectl cert
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.K8S_CLUSTER_ID }}
- name: Apply deployment changes
run: |
envsubst < $GITHUB_WORKSPACE/k8s/worker-deploy.yaml | kubectl apply -f -
- name: Deploy Rollout
run: kubectl rollout restart deployment/$CONTAINER_NAME --namespace $K8S_NAMESPACE
- name: Verify deployment
run: kubectl rollout status deployment/$CONTAINER_NAME --namespace $K8S_NAMESPACE
deploy-worker-topics:
needs: build-worker
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, '~worker') || contains(github.event.head_commit.message, '~topics') }}
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
env:
BACKOFF_INTERVAL: ${{ vars.BACKOFF_INTERVAL }}
BASE_DOMAIN: ${{ vars.BASE_DOMAIN }}
CHROMIUM_EXECUTABLE_PATH: ${{ vars.CHROMIUM_EXECUTABLE_PATH }}
CONTAINER_NAME: ${{ github.event.repository.name }}-worker-${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}-topics
DEEPAI_API_KEY: ${{ secrets.DEEPAI_API_KEY }}
DUPLICATE_LOOKBACK_INTERVAL: ${{ vars.DUPLICATE_LOOKBACK_INTERVAL }}
ENABLED_FEATURES: ${{ vars.ENABLED_FEATURES }}
ERROR_REPORTING: $${{ vars.ERROR_REPORTING }}
K8S_NAMESPACE: ${{ secrets.K8S_NAMESPACE }}
K8S_MEMORY_REQUESTS: ${{ vars.K8S_MEMORY_REQUESTS }}
K8S_CPU_REQUESTS: ${{ vars.K8S_CPU_REQUESTS }}
K8S_MEMORY_LIMITS: ${{ vars.K8S_MEMORY_LIMITS }}
K8S_CPU_LIMITS: ${{ vars.K8S_CPU_LIMITS }}
K8S_REPLICA_COUNT_WORKER: ${{ vars.K8S_REPLICA_COUNT_WORKER_TOPICS || 1 }}
MAIL_HOST: ${{ vars.MAIL_HOST }}
MAIL_PASS: ${{ secrets.MAIL_PASS }}
MAIL_PORT: ${{ vars.MAIL_PORT }}
MAIL_REPLY_TO: ${{ vars.MAIL_REPLY_TO }}
MAIL_USER: ${{ secrets.MAIL_USER }}
MAX_OPENAI_TOKEN_COUNT: ${{ vars.MAX_OPENAI_TOKEN_COUNT }}
OLD_NEWS_THRESHOLD: ${{ vars.OLD_NEWS_THRESHOLD }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PUBLISHER_FETCH_INTERVAL: ${{ vars.PUBLISHER_FETCH_INTERVAL }}
PUBLISHER_FETCH_LIMIT: ${{ vars.PUBLISHER_FETCH_LIMIT }}
PUBLISHER_MAX_ATTEMPT_LIMIT: ${{ vars.PUBLISHER_MAX_ATTEMPT_LIMIT }}
PG_CONNECTION_STRING: ${{ secrets.PG_CONNECTION_STRING }}
PLAY_HT_SECRET_KEY: ${{ secrets.PLAY_HT_SECRET_KEY }}
PLAY_HT_USER_ID: ${{ secrets.PLAY_HT_USER_ID }}
PORT: ${{ vars.PORT }}
RELATIONSHIP_THRESHOLD: ${{ vars.RELATIONSHIP_THRESHOLD }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_KEY: ${{ secrets.S3_KEY }}
S3_SECRET: ${{ secrets.S3_SECRET }}
WORKER_RETRY_EXPRS: ${{ vars.WORKER_RETRY_EXPRS }}
WORKER_QUEUE: topics
steps:
- name: Print Job Description
run: |
echo deploying \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Add kubectl cert
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.K8S_CLUSTER_ID }}
- name: Apply deployment changes
run: |
envsubst < $GITHUB_WORKSPACE/k8s/worker-deploy.yaml | kubectl apply -f -
- name: Deploy Rollout
run: kubectl rollout restart deployment/$CONTAINER_NAME --namespace $K8S_NAMESPACE
- name: Verify deployment
run: kubectl rollout status deployment/$CONTAINER_NAME --namespace $K8S_NAMESPACE
deploy-worker-caches:
needs: build-worker
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, '~worker') || contains(github.event.head_commit.message, '~caches') }}
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
env:
BASE_DOMAIN: ${{ vars.BASE_DOMAIN }}
CACHE_HALFLIFE: ${{ vars.CACHE_HALFLIFE }}
CHROMIUM_EXECUTABLE_PATH: ${{ vars.CHROMIUM_EXECUTABLE_PATH }}
CONTAINER_NAME: ${{ github.event.repository.name }}-worker-${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}-caches
DEEPAI_API_KEY: ${{ secrets.DEEPAI_API_KEY }}
ENABLED_FEATURES: ${{ vars.ENABLED_FEATURES }}
ERROR_REPORTING: $${{ vars.ERROR_REPORTING }}
K8S_NAMESPACE: ${{ secrets.K8S_NAMESPACE }}
K8S_MEMORY_REQUESTS: ${{ vars.K8S_MEMORY_REQUESTS }}
K8S_CPU_REQUESTS: ${{ vars.K8S_CPU_REQUESTS }}
K8S_MEMORY_LIMITS: ${{ vars.K8S_MEMORY_LIMITS }}
K8S_CPU_LIMITS: ${{ vars.K8S_CPU_LIMITS }}
K8S_REPLICA_COUNT_WORKER: ${{ vars.K8S_REPLICA_COUNT_WORKER_CACHES || 1 }}
MAIL_HOST: ${{ vars.MAIL_HOST }}
MAIL_PASS: ${{ secrets.MAIL_PASS }}
MAIL_PORT: ${{ vars.MAIL_PORT }}
MAIL_REPLY_TO: ${{ vars.MAIL_REPLY_TO }}
MAIL_USER: ${{ secrets.MAIL_USER }}
MAX_OPENAI_TOKEN_COUNT: ${{ vars.MAX_OPENAI_TOKEN_COUNT }}
OLD_NEWS_THRESHOLD: ${{ vars.OLD_NEWS_THRESHOLD }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PUBLISHER_FETCH_INTERVAL: ${{ vars.PUBLISHER_FETCH_INTERVAL }}
PUBLISHER_FETCH_LIMIT: ${{ vars.PUBLISHER_FETCH_LIMIT }}
PUBLISHER_MAX_ATTEMPT_LIMIT: ${{ vars.PUBLISHER_MAX_ATTEMPT_LIMIT }}
PG_CONNECTION_STRING: ${{ secrets.PG_CONNECTION_STRING }}
PLAY_HT_SECRET_KEY: ${{ secrets.PLAY_HT_SECRET_KEY }}
PLAY_HT_USER_ID: ${{ secrets.PLAY_HT_USER_ID }}
PORT: ${{ vars.PORT }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_KEY: ${{ secrets.S3_KEY }}
S3_SECRET: ${{ secrets.S3_SECRET }}
WORKER_RETRY_EXPRS: ${{ vars.WORKER_RETRY_EXPRS }}
WORKER_QUEUE: caches
steps:
- name: Print Job Description
run: |
echo deploying \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Add kubectl cert
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.K8S_CLUSTER_ID }}
- name: Apply deployment changes
run: |
envsubst < $GITHUB_WORKSPACE/k8s/worker-deploy.yaml | kubectl apply -f -
- name: Deploy Rollout
run: kubectl rollout restart deployment/$CONTAINER_NAME --namespace $K8S_NAMESPACE
- name: Verify deployment
run: kubectl rollout status deployment/$CONTAINER_NAME --namespace $K8S_NAMESPACE
deploy-worker-notifs:
needs: build-worker
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, '~worker') || contains(github.event.head_commit.message, '~notifs') }}
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
env:
BASE_DOMAIN: ${{ vars.BASE_DOMAIN }}
CHROMIUM_EXECUTABLE_PATH: ${{ vars.CHROMIUM_EXECUTABLE_PATH }}
CONTAINER_NAME: ${{ github.event.repository.name }}-worker-${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}-notifs
DEEPAI_API_KEY: ${{ secrets.DEEPAI_API_KEY }}
ENABLED_FEATURES: ${{ vars.ENABLED_FEATURES }}
ERROR_REPORTING: $${{ vars.ERROR_REPORTING }}
FIREBASE_CREDENTIALS: ${{ secrets.FIREBASE_CREDENTIALS }}
K8S_NAMESPACE: ${{ secrets.K8S_NAMESPACE }}
K8S_MEMORY_REQUESTS: ${{ vars.K8S_MEMORY_REQUESTS }}
K8S_CPU_REQUESTS: ${{ vars.K8S_CPU_REQUESTS }}
K8S_MEMORY_LIMITS: ${{ vars.K8S_MEMORY_LIMITS }}
K8S_CPU_LIMITS: ${{ vars.K8S_CPU_LIMITS }}
K8S_REPLICA_COUNT_WORKER: ${{ vars.K8S_REPLICA_COUNT_WORKER_NOTIFS || 1 }}
MAIL_HOST: ${{ vars.MAIL_HOST }}
MAIL_PASS: ${{ secrets.MAIL_PASS }}
MAIL_PORT: ${{ vars.MAIL_PORT }}
MAIL_REPLY_TO: ${{ vars.MAIL_REPLY_TO }}
MAIL_USER: ${{ secrets.MAIL_USER }}
MAX_OPENAI_TOKEN_COUNT: ${{ vars.MAX_OPENAI_TOKEN_COUNT }}
OLD_NEWS_THRESHOLD: ${{ vars.OLD_NEWS_THRESHOLD }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PUBLISHER_FETCH_INTERVAL: ${{ vars.PUBLISHER_FETCH_INTERVAL }}
PUBLISHER_FETCH_LIMIT: ${{ vars.PUBLISHER_FETCH_LIMIT }}
PUBLISHER_MAX_ATTEMPT_LIMIT: ${{ vars.PUBLISHER_MAX_ATTEMPT_LIMIT }}
PG_CONNECTION_STRING: ${{ secrets.PG_CONNECTION_STRING }}
PLAY_HT_SECRET_KEY: ${{ secrets.PLAY_HT_SECRET_KEY }}
PLAY_HT_USER_ID: ${{ secrets.PLAY_HT_USER_ID }}
PORT: ${{ vars.PORT }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_KEY: ${{ secrets.S3_KEY }}
S3_SECRET: ${{ secrets.S3_SECRET }}
WORKER_RETRY_EXPRS: ${{ vars.WORKER_RETRY_EXPRS }}
WORKER_QUEUE: notifs
steps:
- name: Print Job Description
run: |
echo deploying \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Add kubectl cert
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.K8S_CLUSTER_ID }}
- name: Apply deployment changes
run: |
envsubst < $GITHUB_WORKSPACE/k8s/worker-deploy.yaml | kubectl apply -f -
- name: Deploy Rollout
run: kubectl rollout restart deployment/$CONTAINER_NAME --namespace $K8S_NAMESPACE
- name: Verify deployment
run: kubectl rollout status deployment/$CONTAINER_NAME --namespace $K8S_NAMESPACE