forked from DataDog/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
278 lines (254 loc) · 7.93 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
stages:
- build
- post-deploy
- cleanup
variables:
PREVIEW_CONFIG: "config/preview.yaml"
LIVE_CONFIG: "config/live.yaml"
ARTIFACT_RESOURCE: "public"
LIVE_DOMAIN: "https://docs.datadoghq.com/"
PREVIEW_DOMAIN: "https://docs-staging.datadoghq.com/"
# ================== 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
# ================== templates ================== #
.base_template: &base_template
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/corp-ci:master
tags:
- "runner:main"
- "size:large"
only:
- branches
# ================== preview ================== #
# If the branch has a name of <slack-user>/<feature-name> then ci builds a preview site
build_preview:
<<: *base_template
stage: build
environment: "preview"
variables:
URL: ${PREVIEW_DOMAIN}
CONFIG: ${PREVIEW_CONFIG}
MESSAGE: ":gift_heart: Your preview site is available!\nNow running tests..."
CONFIGURATION_FILE: "./local/bin/py/build/configurations/pull_config_preview.yaml"
LOCAL: "False"
script:
- post_dd_event "documentation deploy ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" "info"
- version_static_assets
- sync_integration_descriptions
#- sync_integration_descriptions_cached
- placehold_translations
- update_preview_baseurl
- build_hugo_site_new
- collect_static_assets
# remove service_checks json as we don't need to s3 push that..
- rm -rf data/service_checks
- push_site_to_s3
- notify_slack "<https://github.com/DataDog/documentation/commit/${CI_COMMIT_SHA}|${CI_COMMIT_REF_NAME}> is ready for preview. <${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}| checks running>." "#31b834"
#- remove_static_from_repo
#- create_artifact
#- create_artifact_untracked
artifacts:
paths:
- ${ARTIFACT_RESOURCE}
- ./integrations_data
only:
- /.+?\/[a-zA-Z0-9_-]+/
link_checks_preview:
<<: *base_template
stage: post-deploy
environment: "preview"
variables:
URL: ${PREVIEW_DOMAIN}
DISALLOW_BOTS: "1"
script:
- node /etc/node_modules/link-checker/dd-link-checker.js -e preview -c ${CI_PROJECT_DIR}/local/etc/link-check-config.js
only:
- /.+?\/[a-zA-Z0-9_-]+/
missing_tms_preview:
<<: *base_template
stage: post-deploy
environment: "preview"
variables:
GIT_STRATEGY: none
dependencies:
- build_preview
script:
- check_missing_tms
only:
- /.+?\/[a-zA-Z0-9_-]+/
index_algolia_preview:
<<: *base_template
stage: post-deploy
environment: "preview"
script:
- cp ./local/etc/algolia/docs_datadoghq_preview.json /etc/docs_datadoghq_preview.json
- index_docsearch_algolia_preview
dependencies:
- build_preview
when: manual
only:
- /.+?\/[a-zA-Z0-9_-]+/
# ================== live ================== #
build_live:
<<: *base_template
stage: build
environment: "live"
variables:
CONFIG: ${LIVE_CONFIG}
URL: ${LIVE_DOMAIN}
UNTRACKED_EXTRAS: "data,content/en/agent/basic_agent_usage/heroku.md,content/en/agent/basic_agent_usage/ansible.md,content/en/agent/basic_agent_usage/chef.md,content/en/agent/basic_agent_usage/puppet.md,content/en/developers/integrations,content/en/developers/amazon_cloudformation.md,content/en/integrations,content/en/logs/log_collection/android.md,content/en/logs/log_collection/ios.md,content/en/tracing/setup/android.md,content/en/tracing/setup/ruby.md"
CONFIGURATION_FILE: "./local/bin/py/build/configurations/pull_config.yaml"
LOCAL: "False"
script:
- post_dd_event "documentation deploy ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" "info"
- notify_slack "<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>" "#FFD700"
- version_static_assets
- sync_integration_descriptions
- sync_integration_metrics
- placehold_translations
- build_hugo_site_new
- collect_static_assets
- push_site_to_s3
- create_artifact
- create_artifact_untracked
artifacts:
when: on_success
paths:
- ${ARTIFACT_RESOURCE}
- ./integrations_data
- content/en
expire_in: 1 week
only:
- master
index_internal_doc:
stage: post-deploy
environment: "live"
image: registry.ddbuild.io/datadoc/webapp:prod-released
dependencies:
- build_live
only:
- master
except: [ tags, schedules ]
tags: [ "runner:docker", "size:large" ]
script:
- INDEXING_SERVICE=https://datadoc.ddbuild.io index-repository hugo https://docs.datadoghq.com/ "Datadog" "Public Documentation" --source_folder=content/en
test_live_link_checks:
<<: *base_template
stage: post-deploy
environment: "live"
variables:
URL: ${LIVE_DOMAIN}
script:
- node /etc/node_modules/link-checker/dd-link-checker.js -e live -c ${CI_PROJECT_DIR}/local/etc/link-check-config.js
only:
- master
index_algolia:
<<: *base_template
stage: post-deploy
environment: "live"
script:
- cp ./local/etc/algolia/docs_datadoghq.json /etc/docs_datadoghq.com
- cat /etc/docs_datadoghq.com
- index_docsearch_algolia
dependencies:
- build_live
only:
- schedules
evaluate_missing_metrics:
<<: *base_template
stage: post-deploy
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')
only:
- master
manage_translations:on-schedule:
<<: *base_template
stage: post-deploy
environment: "live"
variables:
URL: ${PREVIEW_DOMAIN}
CONFIG: ${PREVIEW_CONFIG}
script:
- if [[ $(date +%u) -lt 6 ]]; then manage_translations "${APIKEY}"; fi
- chmod +x ./local/bin/py/translate_metrics.py && ./local/bin/py/translate_metrics.py -k "${APIKEY}" -a $(get_secret 'dd_api_key')
only:
- schedules
#push_translations:
# <<: *base_template
# stage: post-deploy
# environment: "live"
# script:
# - push_changed_translations
# only:
# - master
# except:
# - triggers
# - schedules
test_missing_tms_live:
<<: *base_template
stage: post-deploy
environment: "live"
variables:
GIT_STRATEGY: none
dependencies:
- build_live
script:
- check_missing_tms
only:
- master
test_pa11y:
<<: *base_template
stage: post-deploy
environment: "live"
dependencies:
- build_live
script:
- cp -r /etc/node_modules .
- node ./local/bin/js/pa11y.js --env live --dd_api_key $(get_secret 'dd_api_key')
only:
- schedules
#rollback_live:
# <<: *base_template
# stage: cleanup
# environment: "live"
# when: on_failure
# script:
# - rollback_env
# only:
# - master
tag_successful_live_pipeline:
<<: *base_template
stage: cleanup
environment: "live"
when: on_success
script:
- tag_successful_pipeline
only:
- master
post_success_event_to_dd_live:
<<: *base_template
stage: cleanup
environment: "live"
variables:
GIT_STRATEGY: none
when: on_success
script:
- post_dd_event "documentation deploy ${CI_COMMIT_REF_NAME} succeeded" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" "success"
- post_dd_metric "documentation.pipeline.completed" "1" "" "success"
only:
- master
post_failure_event_to_dd_live:
<<: *base_template
stage: cleanup
environment: "live"
variables:
GIT_STRATEGY: none
when: on_failure
script:
- post_dd_event "documentation deploy ${CI_COMMIT_REF_NAME} failed" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" "error"
- post_dd_metric "documentation.pipeline.completed" "0" "" "failure"
only:
- master