forked from DataDog/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
216 lines (199 loc) · 5.58 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
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:
- find local/bin/ -type f -exec cp {} /usr/local/bin \; # load scripts
- find local/etc/ -type f -exec cp {} /etc \; # load configs
- 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..."
UNTRACKED_EXTRAS: "data,content/integrations"
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
- placehold_translations
- build_hugo_site
- build_hugo_site_ja
- minify_html
- collect_static_assets
- 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
only:
- /.+?\/[a-zA-Z0-9_-]+/
test_preview_images:
<<: *base_template
stage: post-deploy
environment: "preview"
variables:
URL: ${PREVIEW_DOMAIN}
script:
- pull_artifact_from_s3
- test_site_links "images" "${URL}" "True" "False" "True"
only:
- /.+?\/[a-zA-Z0-9_-]+/
test_preview_static:
<<: *base_template
stage: post-deploy
environment: "preview"
variables:
URL: ${PREVIEW_DOMAIN}
script:
- pull_artifact_from_s3
- test_site_links "static" "${URL}" "True" "False" "True"
only:
- /.+?\/[a-zA-Z0-9_-]+/
test_preview_links:
<<: *base_template
stage: post-deploy
environment: "preview"
variables:
URL: ${PREVIEW_DOMAIN}
script:
- pull_artifact_from_s3
- test_site_links "links" "${URL}" "True" "False" "True"
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/integrations"
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
- build_hugo_site_ja
- minify_html
- collect_static_assets
- push_site_to_s3
- create_artifact
- create_artifact_untracked
only:
- master
test_live_images:
<<: *base_template
stage: post-deploy
environment: "live"
variables:
URL: ${LIVE_DOMAIN}
script:
- pull_artifact_from_s3
- test_site_links "images" "${URL}" "True" "False" "True"
only:
- master
test_live_links:
<<: *base_template
stage: post-deploy
environment: "live"
variables:
URL: ${LIVE_DOMAIN}
script:
- pull_artifact_from_s3
- test_site_links "links" "${URL}" "True" "False" "True"
only:
- master
test_live_static:
<<: *base_template
stage: post-deploy
environment: "live"
variables:
URL: ${LIVE_DOMAIN}
script:
- pull_artifact_from_s3
- test_site_links "static" "${URL}" "True" "False" "True"
only:
- master
#index_algolia:
# <<: *base_template
# stage: post-deploy
# environment: "live"
# script:
# - pull_artifact_from_s3
# - index_algolia
# only:
# - master
manage_translations:on-schedule:
<<: *base_template
stage: post-deploy
environment: "live"
variables:
URL: ${PREVIEW_DOMAIN}
CONFIG: ${PREVIEW_CONFIG}
script:
- manage_translations "${APIKEY}"
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"
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"
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