17
17
required : false
18
18
type : string
19
19
default : " *"
20
- force :
21
- description : " Force new build and deploy"
20
+ build :
21
+ description : " Force new build"
22
+ required : false
23
+ type : boolean
24
+ default : false
25
+ deploy :
26
+ description : " Force new deployment"
22
27
required : false
23
28
type : boolean
24
29
default : false
46
51
CODER_BASE_IMAGE_TAG : ${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}
47
52
CODER_IMAGE_TAG : ${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}
48
53
NEW : ${{ steps.check_deployment.outputs.new }}
49
- BUILD : ${{ steps.filter.outputs.all_count > steps.filter.outputs.ignored_count || steps.check_deployment.outputs.new || github.event.inputs.force == 'true' }}
54
+ BUILD : ${{ steps.filter.outputs.all_count > steps.filter.outputs.ignored_count || steps.check_deployment.outputs.new || github.event.inputs.build == 'true' }}
50
55
51
56
runs-on : " ubuntu-latest"
52
57
steps :
@@ -209,7 +214,7 @@ jobs:
209
214
# Run deploy job only if build job was successful or skipped
210
215
if : |
211
216
always() && (needs.build.result == 'success' || needs.build.result == 'skipped') &&
212
- (github.event_name == 'workflow_dispatch' || needs.get_info.outputs.NEW == 'false')
217
+ (github.event_name == 'workflow_dispatch' || needs.get_info.outputs.NEW == 'false' || github.event.inputs.deploy == 'true' )
213
218
runs-on : " ubuntu-latest"
214
219
env :
215
220
CODER_IMAGE_TAG : ${{ needs.get_info.outputs.CODER_IMAGE_TAG }}
@@ -227,7 +232,7 @@ jobs:
227
232
export KUBECONFIG=~/.kube/config
228
233
229
234
- name : Check if image exists
230
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
235
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
231
236
run : |
232
237
set -euo pipefail
233
238
foundTag=$(curl -fsSL https://github.com/coder/coder/pkgs/container/coder-preview | grep -o ${{ env.CODER_IMAGE_TAG }} | head -n 1)
@@ -238,7 +243,7 @@ jobs:
238
243
fi
239
244
240
245
- name : Add DNS record to Cloudflare
241
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
246
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
242
247
run : |
243
248
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.PR_DEPLOYMENTS_ZONE_ID }}/dns_records" \
244
249
-H "Authorization: Bearer ${{ secrets.PR_DEPLOYMENTS_CLOUDFLARE_API_TOKEN }}" \
@@ -251,15 +256,15 @@ jobs:
251
256
ref : ${{ env.PR_BRANCH }}
252
257
253
258
- name : Create PR namespace
254
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
259
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
255
260
run : |
256
261
set -euo pipefail
257
262
# try to delete the namespace, but don't fail if it doesn't exist
258
263
kubectl delete namespace "pr${{ env.PR_NUMBER }}" || true
259
264
kubectl create namespace "pr${{ env.PR_NUMBER }}"
260
265
261
266
- name : Check and Create Certificate
262
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
267
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
263
268
run : |
264
269
# Using kubectl to check if a Certificate resource already exists
265
270
# we are doing this to avoid letsenrypt rate limits
@@ -282,7 +287,7 @@ jobs:
282
287
)
283
288
284
289
- name : Set up PostgreSQL database
285
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
290
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
286
291
run : |
287
292
helm repo add bitnami https://charts.bitnami.com/bitnami
288
293
helm install coder-db bitnami/postgresql \
@@ -295,18 +300,18 @@ jobs:
295
300
--from-literal=url="postgres://coder:coder@coder-db-postgresql.pr${{ env.PR_NUMBER }}.svc.cluster.local:5432/coder?sslmode=disable"
296
301
297
302
- name : Create a kubeconfig for the workspace
298
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
303
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
299
304
run : |
300
305
set -euo pipefail
301
306
# Create service account, role, rolebinding and secret
302
307
envsubst < ./.github/pr-deployments/rbac.yaml | kubectl apply -f -
303
308
304
309
# Get the token for the service account
305
- TOKEN=$(kubectl -n pr${{ env.PR_NUMBER }} get secret coder-workspace-token -o jsonpath='{.data.token}' | base64 --decode)
310
+ export TOKEN=$(kubectl -n pr${{ env.PR_NUMBER }} get secret coder-workspace-token -o jsonpath='{.data.token}' | base64 --decode)
306
311
307
312
# get CLUSTER_CA and CLUSTER_ENDPOINT
308
- CLUSTER_CA=$(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}')
309
- CLUSTER_ENDPOINT=$(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.server}')
313
+ export CLUSTER_CA=$(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}')
314
+ export CLUSTER_ENDPOINT=$(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.server}')
310
315
311
316
# Create a kubeconfig for the namespace to be used in the workspace
312
317
envsubst < ./.github/pr-deployments/kubeconfig.yaml > ./namespace-kubeconfig.yaml
@@ -344,15 +349,15 @@ jobs:
344
349
fi
345
350
346
351
- name : Install coder-logstream-kube
347
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
352
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
348
353
run : |
349
354
helm repo add coder-logstream-kube https://helm.coder.com/logstream-kube
350
355
helm upgrade --install coder-logstream-kube coder-logstream-kube/coder-logstream-kube \
351
356
--namespace "pr${{ env.PR_NUMBER }}" \
352
357
--set url="https://pr${{ env.PR_NUMBER }}.${{ secrets.PR_DEPLOYMENTS_DOMAIN }}"
353
358
354
359
- name : Get Coder binary
355
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
360
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
356
361
run : |
357
362
set -euo pipefail
358
363
@@ -378,7 +383,7 @@ jobs:
378
383
mv "${DEST}" /usr/local/bin/coder
379
384
380
385
- name : Create first user, template and workspace
381
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
386
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
382
387
id : setup_deployment
383
388
run : |
384
389
set -euo pipefail
@@ -415,7 +420,7 @@ jobs:
415
420
coder stop kube -y
416
421
417
422
- name : Send Slack notification
418
- if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.force == 'true'
423
+ if : needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
419
424
run : |
420
425
curl -s -o /dev/null -X POST -H 'Content-type: application/json' \
421
426
-d \
0 commit comments