-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
.gitlab-ci.yml
674 lines (629 loc) · 23.4 KB
/
.gitlab-ci.yml
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
stages:
- bootstrap
- build
- post-deploy
- cleanup
# set pipeline type for merge queue
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
variables:
PIPELINE_TYPE: 'schedule'
- if: '$CI_PIPELINE_SOURCE == "api"'
variables:
PIPELINE_TYPE: 'api'
- if: '$CI_COMMIT_BRANCH == $GIT_BASE_BRANCH'
variables:
PIPELINE_TYPE: 'main-branch'
- if: '$CI_COMMIT_BRANCH =~ /^mq-working-branch-/'
variables:
PIPELINE_TYPE: 'merge-queue'
- when: always
variables:
PIPELINE_TYPE: 'feature-branch'
variables:
PREVIEW_CONFIG: "config/preview.yaml"
LIVE_CONFIG: "config/live.yaml"
HUGO_CACHEDIR: "${CI_PROJECT_DIR}/hugo_cache/"
ARTIFACT_RESOURCE: "public"
LIVE_DOMAIN: "https://docs.datadoghq.com/"
PREVIEW_DOMAIN: "https://docs-staging.datadoghq.com/"
KUBERNETES_SERVICE_ACCOUNT_OVERWRITE: documentation
KUBERNETES_CPU_REQUEST: 8
KUBERNETES_MEMORY_REQUEST: 32Gi
KUBERNETES_MEMORY_LIMIT: 32Gi
# datadog-ci
DATADOG_SITE: 'datadoghq.com'
DATADOG_SUBDOMAIN: 'dd-corpsite'
FORCE_COLOR: '1'
GIT_DEPTH: 50
DEFAULT_TAGS: "environment:${CI_ENVIRONMENT_NAME},job_name:${CI_JOB_NAME},job_stage:${CI_JOB_STAGE},project_name:${CI_PROJECT_NAME},docker_image:${CI_REGISTRY_IMAGE},pipeline_id:${CI_PIPELINE_ID},service:gitlab,pipeline_source:${CI_PIPELINE_SOURCE}"
FF_USE_FASTZIP: "true"
# These can be specified per job or per pipeline
ARTIFACT_COMPRESSION_LEVEL: "fast"
CACHE_COMPRESSION_LEVEL: "fast"
# gitlab checkout
DOCS_REPO_NAME: documentation
REPO_URL: "https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/${DOCS_REPO_NAME}.git"
# yarn/node cache dirs
YARN_CACHE_FOLDER: "${CI_PROJECT_DIR}/.yarn/cache/"
PREVIEW_PATTERN: '/.+?\/[a-zA-Z0-9_-]+/'
PREVIEW_ERROR_LOG: "/go/src/github.com/DataDog/documentation/preview_error.log"
PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.pipcache/"
URGENT_FIX: "false" # set to true if the branch is an urgent fix to skip the build_live queue
# ================== copy scripts =============== #
before_script:
- "[ -d local/bin ] && find local/bin/ -type f -exec cp {} /usr/local/bin \\;" # load scripts
- "[ -d local/etc ] && find local/etc/ -type f -exec cp {} /etc \\;" # load configs
- "[ -f /usr/local/bin/helpers.sh ] && source /usr/local/bin/helpers.sh" # source helpers so they are available in the container
- chmod +x /usr/local/bin/*.py # make python scripts executable by the runner
- "[ -f /etc/profile ] && source /etc/profile" # for golang on path
- mkdir -p logs
# set common env variables for this shell
- export GITHUB_TOKEN=$(get_secret 'github_token')
- export DATADOG_API_KEY=$(get_secret 'dd-api-key')
- export DATADOG_APP_KEY=$(get_secret 'dd-app-key')
- export BRANCH=${CI_COMMIT_REF_NAME}
- export SLACK_URL=$(get_secret 'slack_url')
- export WEBOPS_SLACK_URL=$(get_secret 'webops_slack_url')
- export IA_SUBDOMAIN=$(in-isolation get_ia_subdomain)
- git config --global url."https://${GITHUB_TOKEN}@github.com/DataDog".insteadOf https://github.com/DataDog
- type build_dogrc &>/dev/null && build_dogrc || echo "build_dogrc not found." # create .dogrc for metrics, events submission
- export job_start=$(date +%s) # we need the start of each job recorded for the ci reporting
# set policy for the common case
# hugo cache is used only in the build job so lets pull-push
.hugo_cache: &hugo_cache
- key:
files:
- go.sum
paths:
- ${HUGO_CACHEDIR}
policy: pull-push
# set policy for the common case
# yarn cache is used in a lot but only built during build job so lets default to pull and explicit push in build job
.yarn_cache: &yarn_cache
- key:
files:
- yarn.lock
paths:
- package.json
- yarn.lock
- ${YARN_CACHE_FOLDER}
policy: pull
.yarn_cache_pull_push: &yarn_cache_pull_push
- key:
files:
- yarn.lock
paths:
- package.json
- yarn.lock
- ${YARN_CACHE_FOLDER}
policy: pull-push
.pip_cache: &pip_cache
- key:
files:
- local/etc/requirements3.txt
paths:
- ${PIP_CACHE_DIR}
policy: pull-push
# ==================== rules ==================== #
.preview_rules: &preview_rules
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH =~ $PREVIEW_PATTERN
when: on_success
.if_mergequeue: &if_mergequeue
rules:
- if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
when: always
.preview_manual_rules: &preview_manual_rules
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH =~ $PREVIEW_PATTERN
when: manual
.live_rules: &live_rules
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $URGENT_FIX == "false"
when: on_success
.live_urgent_fix_rules: &live_urgent_fix_rules
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $URGENT_FIX == "true"
when: on_success
.live_schedule_rules: &live_schedule_rules
rules:
- if: $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule"
when: on_success
# ================== templates ================== #
.base_template: &base_template
image: registry.ddbuild.io/ci/websites/webops-site-build:v42145832-00d7fc2f
tags:
- "arch:amd64"
rules:
- if: $CI_COMMIT_TAG != null # Variable exists on tag workflows
when: never
- if: $CI_COMMIT_BRANCH != null # Variable doesnt exists on merge request pipelines or tag pipelines.
when: on_success
# ================== preview ================== #
# If the branch has a name of <slack-user>/<feature-name> then ci builds a preview site
build_preview:
<<: *base_template
rules:
- !reference [.preview_rules, rules ]
- !reference [.if_mergequeue, rules ]
stage: build
cache:
- *hugo_cache
- *yarn_cache_pull_push
- *pip_cache
environment: "preview"
variables:
URL: ${PREVIEW_DOMAIN}
CONFIG: ${PREVIEW_CONFIG}
MESSAGE: ":gift_heart: Your preview site is available! Now running tests..."
CONFIGURATION_FILE: "./local/bin/py/build/configurations/pull_config_preview.yaml"
LOCAL: "False"
script:
- dog --config "$HOME/.dogrc" event post "documentation build ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" --alert_type "info" --tags="${DEFAULT_TAGS}"
- touch Makefile.config
- touch preview_error.log # Create log file for errors
- exec 2> $PREVIEW_ERROR_LOG # We want to output any detected error to a log for use in notifications
- make dependencies
- make config
- ./node_modules/.bin/jest --testPathPattern=assets/scripts/tests/
- yarn run prebuild
- make update_websites_sources_module
- build_site
# remove service_checks json as we don't need to s3 push that..
- rm -rf data/service_checks
- in-isolation deploy_site
# remove static images so we can skip from artifact passed in gitlab
- remove_static_from_repo
- notify_slack.py "Your branch ${CI_COMMIT_REF_NAME} is ready for preview. <${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}| checks running>." --status="#31b834" --previewSite="true"
- ci_pass_step "${CI_PROJECT_NAME}-${CI_JOB_NAME}" # run at completion of job, if job fails at any point prior this won't run
artifacts:
when: always
paths:
- ${ARTIFACT_RESOURCE}
- ./integrations_data
- .github/
- .vale.ini
- .htmltest.yml
- ./logs
- ./public/redirects.txt
- $PREVIEW_ERROR_LOG
- ./latest-cached.tar.gz
- typesense.config.json
after_script:
- |
if [ -s $PREVIEW_ERROR_LOG ] && [ $CI_JOB_STATUS != 'success' ]; then
echo "Error Detected: $(cat $PREVIEW_ERROR_LOG)";
fi # Output the error to the console
interruptible: true
link_checks_preview:
<<: *base_template
rules:
- !reference [.preview_rules, rules ]
- !reference [.if_mergequeue, rules ]
stage: post-deploy
cache: {}
environment: "preview"
variables:
URL: ${PREVIEW_DOMAIN}
GIT_STRATEGY: none
script:
- dog --config "$HOME/.dogrc" event post "documentation htmltest ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" --alert_type "info" --tags="${DEFAULT_TAGS}"
- find ./public -name "*.html" -exec sed -i -e "s#https://docs-staging.datadoghq.com/$CI_COMMIT_REF_NAME/#/#g" {} +
- find ./public -name "*.html" -exec sed -i -e "s#/api/v1/#/api/latest/#g" {} +
- find ./public -name "*.html" -exec sed -i -e "s#/api/v2/#/api/latest/#g" {} +
- htmltest
after_script:
- "[ -f /usr/local/bin/helpers.sh ] && source /usr/local/bin/helpers.sh" # source helpers
- RESULT="⛈ htmltest result; the following issues were found:\n$(tail -n +2 ./tmp/.htmltest/htmltest.log)\n--------------------" # output all but first line
- if grep -q "not exist" tmp/.htmltest/htmltest.log; then notify_slack.py "${RESULT}" --status="#31b834"; fi
artifacts:
paths:
- ./tmp/.htmltest
interruptible: true
missing_tms_preview:
<<: *base_template
rules:
- !reference [.preview_rules, rules ]
- !reference [.if_mergequeue, rules ]
stage: post-deploy
environment: "preview"
allow_failure: true
cache: {}
dependencies:
- build_preview
script:
- check_missing_tms
interruptible: true
typesense_sync_preview:manual:
<<: *base_template
stage: post-deploy
environment: "preview"
allow_failure: true
interruptible: true
timeout: 2h
cache:
- *hugo_cache
- *yarn_cache
- *pip_cache
dependencies:
- build_preview
script:
# build the site to get search.json ondemand
- touch Makefile.config preview_error.log
- make dependencies
- make config
- yarn run prebuild
- build_site
# end build
- >
TYPESENSE_ADMIN_API_KEY=$(get_secret 'typesense_preview_admin_api_key')
TYPESENSE_HOST=$(get_secret 'typesense_preview_host')
TYPESENSE_CONFIG_UPDATED=$(git diff $CI_DEFAULT_BRANCH... --name-only | grep typesense.config.json)
yarn run typesense:sync:preview
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: never
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_TAG =~ "/^$/"'
when: manual
typesense_sync_live:
<<: *base_template
<<: *live_rules
stage: post-deploy
environment: "live"
allow_failure: true
interruptible: true
timeout: 2h
dependencies:
- build_live
script:
- yarn add typesense-sync@https://s3.amazonaws.com/origin-static-assets/corp-node-packages/master/typesense-sync-v1.0.8.tgz
- >
TYPESENSE_ADMIN_API_KEY=$(get_secret 'typesense_prod_admin_api_key')
TYPESENSE_HOST=$(get_secret 'typesense_prod_host')
TYPESENSE_CONFIG_UPDATED=$(git diff $CI_DEFAULT_BRANCH... --name-only | grep typesense.config.json)
yarn run typesense:sync:production
sourcemaps_preview:
<<: *base_template
<<: *preview_rules
stage: post-deploy
cache:
- *yarn_cache
environment: "preview"
script:
- yarn install --immutable
# Rename any js.map files to include SHA if correlating JS file is fingerprinted. Hugo's asset build system seems to lose the fingerprint value when generating source maps.
- find ./public -type f -name "*.*.js" -exec bash -c 'x={}; hash=$(basename $x | cut -d '.' -f 2); map=${x/$hash./}.map; mv $map ${map/.js/.$hash.js}' \;
- DATADOG_API_KEY="$(get_secret 'dd-api-key')" ./node_modules/.bin/datadog-ci sourcemaps upload ./public/static --service docs --minified-path-prefix "https://docs-staging.datadoghq.com/${CI_COMMIT_REF_NAME}/static/" --release-version "${CI_COMMIT_SHORT_SHA}"
dependencies:
- build_preview
allow_failure: true
interruptible: true
post_build_success_status_to_spec_repo:
<<: *base_template
stage: cleanup
cache: {}
environment: "preview"
script:
- chmod +x ./local/bin/py/submit_github_status_check.py
- ./local/bin/py/submit_github_status_check.py -i "$(get_secret 'dd-api-spec-repo-app-id')" -k "$(get_secret 'dd-api-spec-repo-app-key')"
rules:
- if: $CI_COMMIT_BRANCH =~ /^datadog-api-spec\/generated.*/
when: on_success
interruptible: true
allow_failure: true
post_build_failure_status_to_spec_repo:
<<: *base_template
stage: cleanup
cache: {}
environment: "preview"
script:
- chmod +x ./local/bin/py/submit_github_status_check.py
- ./local/bin/py/submit_github_status_check.py -s "failure" -i "$(get_secret 'dd-api-spec-repo-app-id')" -k "$(get_secret 'dd-api-spec-repo-app-key')"
rules:
- if: $CI_COMMIT_BRANCH =~ /^datadog-api-spec\/generated.*/
when: on_failure
interruptible: true
allow_failure: true
# ================== live ================== #
.build_live_template: &build_live_template
<<: *base_template
stage: build
cache:
- *hugo_cache
- *yarn_cache_pull_push
- *pip_cache
environment: "live"
retry: 1
variables:
CONFIG: ${LIVE_CONFIG}
URL: ${LIVE_DOMAIN}
UNTRACKED_EXTRAS: "data"
CONFIGURATION_FILE: "./local/bin/py/build/configurations/pull_config.yaml"
LOCAL: "False"
RESOURCE_GROUP_ORDER: oldest_first
RESOURCE_GROUP_LIMIT: 1
script:
- dog --config "$HOME/.dogrc" event post "documentation deploy ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" --alert_type "info" --tags="${DEFAULT_TAGS}"
- notify_slack.py "<https://github.com/DataDog/documentation/commit/${CI_COMMIT_SHA}|${CI_COMMIT_SHA:0:8}> sent to gitlab for production deployment. <${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}|details>" --status="#FFD700"
- touch Makefile.config
- make clean-examples
- make dependencies
- make vector_data
- yarn run prebuild
- make update_websites_sources_module
- build_site
- in-isolation deploy_site
- in-isolation create_artifact
- in-isolation create_artifact_ignored
- in-isolation create_artifact_cached
- remove_static_from_repo
- ci_pass_step "${CI_PROJECT_NAME}-${CI_JOB_NAME}" # run at completion of job, if job fails at any point prior this won't run
artifacts:
when: on_success
paths:
- ${ARTIFACT_RESOURCE}
- ./integrations_data
- content/en
- .htmltest.yml
- ./public/redirects.txt
- typesense.config.json
expire_in: 1 week
# Standard master build job
build_live:
<<: *build_live_template
<<: *live_rules
environment: "live"
resource_group: build_live_group
# Urgent fix build job
build_live_urgent:
<<: *build_live_template
<<: *live_urgent_fix_rules
environment: "live"
resource_group: build_live_urgent_group
test_live_link_checks:
<<: *base_template
<<: *live_rules
stage: post-deploy
cache: {}
environment: "live"
variables:
URL: ${LIVE_DOMAIN}
GIT_STRATEGY: none
script:
- dog --config "$HOME/.dogrc" event post "documentation htmltest ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" --alert_type "info" --tags="${DEFAULT_TAGS}"
- find ./public -name "*.html" -exec sed -i -e "s#https://docs.datadoghq.com/#/#g" {} +
- find ./public -name "*.html" -exec sed -i -e "s#/api/v1/#/api/latest/#g" {} +
- find ./public -name "*.html" -exec sed -i -e "s#/api/v2/#/api/latest/#g" {} +
- htmltest
after_script:
- "[ -f /usr/local/bin/helpers.sh ] && source /usr/local/bin/helpers.sh" # source helpers
- RESULT="⛈ htmltest result; the following issues were found:\n$(tail -n +2 ./tmp/.htmltest/htmltest.log)\n--------------------" # output all but first line
- if grep -q "not exist" tmp/.htmltest/htmltest.log; then notify_slack.py "${RESULT}" --status="#31b834"; fi
artifacts:
paths:
- ./tmp/.htmltest
sourcemaps_live:
<<: *base_template
<<: *live_rules
stage: post-deploy
cache:
- *yarn_cache
environment: "live"
script:
- yarn install --immutable
# Rename any js.map files to include SHA if correlating JS file is fingerprinted. Hugo's asset build system seems to lose the fingerprint value when generating source maps.
- find ./public -type f -name "*.*.js" -exec bash -c 'x={}; hash=$(basename $x | cut -d '.' -f 2); map=${x/$hash./}.map; mv $map ${map/.js/.$hash.js}' \;
- DATADOG_API_KEY="$(get_secret 'dd-api-key')" ./node_modules/.bin/datadog-ci sourcemaps upload ./public/static --service docs --minified-path-prefix "https://docs.datadoghq.com/static/" --release-version "${CI_COMMIT_SHORT_SHA}"
dependencies:
- build_live
allow_failure: true
evaluate_missing_metrics:
<<: *base_template
stage: post-deploy
allow_failure: true
cache: {}
environment: "live"
script:
- chmod +x ./local/bin/py/missing_metrics.py && ./local/bin/py/missing_metrics.py -k $(get_secret 'dd-demo-api-key') -p $(get_secret 'dd-demo-app-key') -a $(get_secret 'dd-api-key') -b $(get_secret 'dd-app-key')
rules:
- if: $CI_COMMIT_REF_NAME == "master"
when: manual
# Uploads git ignored source (EN) files to Transifex as part of the nightly build.
# The translation syncing pipeline is triggered by github webhook, but these files are not in git.
# This allows some dynamically built content (such as integrations) to be localized automatically.
manage_ignored_translations:on-schedule:
<<: *base_template
<<: *live_schedule_rules
stage: post-deploy
cache: {}
environment: "live"
script:
- echo "Downloading ignored translation source files..."
- manage_ignored_translation_files
# This checks anchor links,
# its too noisy to run all the time but we want some insight so its running on schedule
link_checks:on-schedule:
<<: *base_template
<<: *live_schedule_rules
stage: post-deploy
cache: {}
environment: "live"
variables:
URL: ${LIVE_DOMAIN}
GIT_STRATEGY: none
dependencies:
- build_live
script:
- dog --config "$HOME/.dogrc" event post "documentation htmltest ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" --alert_type "info" --tags="${DEFAULT_TAGS}"
- find ./public -name "*.html" -exec sed -i -e "s#https://docs.datadoghq.com/#/#g" {} +
- find ./public -name "*.html" -exec sed -i -e "s#/api/v1/#/api/latest/#g" {} +
- find ./public -name "*.html" -exec sed -i -e "s#/api/v2/#/api/latest/#g" {} +
- "sed -i'' -e 's/CheckInternalHash: false/CheckInternalHash: true/' .htmltest.yml"
- htmltest
artifacts:
paths:
- ./tmp/.htmltest
interruptible: true
allow_failure: true
# We are relying on the preview version of this job due to the length of time it takes
# test_missing_tms_live:
# <<: *base_template
# <<: *live_rules
# stage: post-deploy
# cache: {}
# environment: "live"
# dependencies:
# - build_live
# script:
# - check_missing_tms
# template for what runs in pa11y to avoid duplication
.pa11y_live_template: &pa11y_live_template
image: registry.ddbuild.io/ci/websites/pa11y:v48852638-b2768bdb
tags: ["arch:amd64"]
stage: post-deploy
cache: []
variables:
GIT_STRATEGY: none
script:
- unset NODE_OPTIONS
- cp -r ${ARTIFACT_RESOURCE} /app # copy the artifact to the working diretory of this docker container
- cd /app # go into working directory
- export CI_PROJECT_DIR="." # override project dir so pa11y script can locate the generated csv and push to s3
- node ./index.js --env live --site docs --dd_api_key "$(get_secret 'dd_synthetic_api_key_prod')" # run pa11y
interruptible: true
run_pa11y:schedule:
<<: *pa11y_live_template
dependencies:
- build_live
rules:
- if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "schedule"
when: always
- if: $CI_COMMIT_TAG != null || $CI_COMMIT_BRANCH =~ "/pull/\/.*/"
when: never
timeout: 2h
run_pa11y:manual:
<<: *pa11y_live_template
allow_failure: true # https://gitlab.com/gitlab-org/gitlab/-/issues/39534 Need to allow failure to not get a blocked status
rules:
- if: $CI_COMMIT_TAG != null || $CI_COMMIT_BRANCH =~ "/pull/\/.*/"
when: never
- if: $CI_COMMIT_TAG == null
when: manual
timeout: 2h
tag_successful_live_pipeline:
<<: *base_template
<<: *live_rules
stage: cleanup
cache: {}
environment: "live"
when: on_success
script:
- tag_successful_pipeline
post_success_event_to_dd_live:
<<: *base_template
<<: *live_rules
stage: cleanup
cache: {}
environment: "live"
variables:
GIT_STRATEGY: none
script:
- dog --config "$HOME/.dogrc" event post "documentation deploy ${CI_COMMIT_REF_NAME} succeeded" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" --alert_type "info" --tags="${DEFAULT_TAGS}"
- dog --config "$HOME/.dogrc" metric post "documentation.pipeline.completed" "1" --tags="${DEFAULT_TAGS},step_status:success"
post_failure_event_to_dd_live:
<<: *base_template
stage: cleanup
cache: {}
environment: "live"
variables:
GIT_STRATEGY: none
script:
- dog --config "$HOME/.dogrc" event post "documentation deploy ${CI_COMMIT_REF_NAME} failed" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" --alert_type "error" --tags="${DEFAULT_TAGS},step_status:failure"
- dog --config "$HOME/.dogrc" metric post "documentation.pipeline.completed" "0" --tags="${DEFAULT_TAGS},step_status:failure"
rules:
- if: $CI_COMMIT_REF_NAME == "master"
when: on_failure
set_redirect_metadata_preview:
<<: *base_template
<<: *preview_rules
variables:
BUCKET: "datadog-docs-preview"
SET_REDIRECTS_PREVIEW: "true"
stage: post-deploy
cache: []
environment: "preview"
dependencies:
- build_preview
script:
- in-isolation run_update_redirect_metadata
interruptible: true
allow_failure: true
set_redirect_metadata_live:
<<: *base_template
<<: *live_rules
variables:
BUCKET: "datadog-docs-live-hugo"
stage: post-deploy
cache: []
environment: "live"
dependencies:
- build_live
script:
- in-isolation run_update_redirect_metadata
interruptible: true
run_notranslate_tag:schedule:
<<: *base_template
stage: post-deploy
cache: []
dependencies:
- build_live
timeout: 4h
script:
- python3 -m venv ./venv && source ./venv/bin/activate && pip install transifex-python
- export transifex_api_key="$(get_secret 'transifex_api_key')"
- source ./venv/bin/activate && python3 ./local/bin/py/add_notranslate_tag.py
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule"
when: always
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
- when: never
# run_notranslate_tag:manual:
# <<: *base_template
# <<: *live_schedule_rules
# allow_failure: true
# stage: post-deploy
# timeout: 2h
# script:
# - export transifex_api_key="$(get_secret 'transifex_api_key')"
# - python3 ./local/bin/py/add_notranslate_tag.py
# rules:
# - if: $CI_COMMIT_TAG != null || $CI_COMMIT_BRANCH =~ "/pull/\/.*/"
# when: never
# - if: $CI_COMMIT_TAG == null
# when: manual
####################################
# #
# Failure Notifications #
# #
####################################
failure_notification_preview:
<<: *base_template
stage: cleanup
environment: "preview"
variables:
GIT_STRATEGY: none
script:
- |
if [ -s preview_error.log ]; then
SLACK_MESSAGE=":siren: A gitlab job for your branch has failed with the following error: $(tail -n 10 preview_error.log)";
else
SLACK_MESSAGE=":siren: A gitlab job for your branch has failed due to an error, please check your pipeline"; # Safety in case the error log is empty
fi
- notify_slack.py "${SLACK_MESSAGE}" --status="#ab0000" --previewSite="false" --link="${CI_PIPELINE_URL}" --buttonContent="Gitlab Pipeline :looking:"
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH =~ $PREVIEW_PATTERN
when: on_failure