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
|
image: ruby:2.5
stages:
- images
- build
- test
- deploy
- docker-stable
#
# Pick the remote branch, by default master (see the Rakefile for more info)
#
variables:
BRANCH_CE: 'master'
BRANCH_EE: 'master'
BRANCH_OMNIBUS: 'master'
BRANCH_RUNNER: 'master'
before_script:
- ruby -v
- bundle install --jobs 4 --path vendor
###############################################
# Build the website #
###############################################
.build_base: &build_base
stage: build
script:
- rake setup_git default
- nanoc compile -VV
artifacts:
paths:
- public
expire_in: 1w
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
paths:
- tmp/
- vendor/ruby
tags:
- docker
#
# Compile only on master and stable branches
#
compile_prod:
<<: *build_base
variables:
NANOC_ENV: 'production'
only:
- master
- /^\d{1,2}\.\d{1,2}$/
#
# Compile on all branches except master
#
compile_dev:
<<: *build_base
only:
- branches
except:
- master
- /^\d{1,2}\.\d{1,2}$/
###############################################
# Test the website #
###############################################
#
# Check for 404s in internal links
#
internal_links:
stage: test
script:
- nanoc check internal_links
allow_failure: true
cache:
key: "test-$CI_COMMIT_REF_NAME"
paths:
- vendor/ruby
tags:
- docker
# Skip this job when it's invoked by a cross project pipeline. That will speed
# up the pipeline when a docs preview is triggered. We already check for
# internal links in every MR anyway. For more info:
# https://docs.gitlab.com/ee/development/writing_documentation.html#previewing-the-changes-live
except:
- pipelines
#
# SCSS linting
#
scss_lint:
stage: test
script:
- bundle exec scss-lint
cache:
key: "test-$CI_COMMIT_REF_NAME"
paths:
- vendor/ruby
tags:
- docker
# Skip this job when it's invoked by a cross project pipeline. That will speed
# up the pipeline when a docs preview is triggered. The triggered pipeline is
# always a branch off master which should be green anyway. For more info:
# https://docs.gitlab.com/ee/development/writing_documentation.html#previewing-the-changes-live
except:
- pipelines
###############################################
# Review Apps #
###############################################
#
# Deploy the Review App on a dev server
#
review:
stage: deploy
variables:
GIT_STRATEGY: none
dependencies:
- compile_dev
before_script: []
cache: {}
script:
- rsync -av --delete public /srv/nginx/pages/$CI_COMMIT_REF_SLUG
environment:
name: review/$CI_COMMIT_REF_SLUG
url: http://$CI_COMMIT_REF_SLUG.$APPS_DOMAIN
on_stop: review_stop
only:
- branches@gitlab-com/gitlab-docs
# Except master and stable branches
except:
- master
- /^\d{1,2}\.\d{1,2}$/
tags:
- nginx
- review-apps
#
# Stop the Review App
#
review_stop:
stage: deploy
variables:
GIT_STRATEGY: none
dependencies: []
artifacts: {}
before_script: []
cache: {}
script:
- rm -rf public /srv/nginx/pages/$CI_COMMIT_REF_SLUG
when: manual
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop
only:
- branches@gitlab-com/gitlab-docs
# Except master and stable branches
except:
- master
- /^\d{1,2}\.\d{1,2}$/
tags:
- nginx
- review-apps
###############################################
# GitLab Pages (production) #
###############################################
#
# Deploy to production with GitLab Pages
#
pages:
stage: deploy
variables:
GIT_STRATEGY: none
before_script: []
cache: {}
environment:
name: production
url: https://docs.gitlab.com
script:
# Symlink all README.html to index.html
- for i in `find public -name README.html`; do ln -sf README.html $(dirname $i)/index.html; done
artifacts:
paths:
- public
expire_in: 1h
only:
- master@gitlab-com/gitlab-docs
tags:
- docker
dependencies:
- compile_prod
###############################################
# Docker images builds #
###############################################
.docker_build: &docker_build
image: docker:latest
services:
- docker:dind
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
#
# Except stable branches with versions like 10.4
#
.except_stable: &except_stable
except:
- /^\d{1,2}\.\d{1,2}$/
#
# Build the image containing all build dependencies
#
image:bootstrap:
stage: images
<<: *docker_build
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:bootstrap
script:
- docker build -t $IMAGE_NAME -f dockerfiles/Dockerfile.bootstrap .
- docker push $IMAGE_NAME
when: manual
<<: *except_stable
#
# Build the image that takes the website and builds it
#
image:builder-onbuild:
stage: images
<<: *docker_build
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:builder-onbuild
script:
- docker build -t $IMAGE_NAME -f dockerfiles/Dockerfile.builder.onbuild .
- docker push $IMAGE_NAME
when: manual
<<: *except_stable
#
# Build the image that copies the final HTML files in a smaller image
#
image:nginx-onbuild:
stage: images
<<: *docker_build
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:nginx-onbuild
script:
- docker build -t $IMAGE_NAME -f dockerfiles/Dockerfile.nginx.onbuild .
- docker push $IMAGE_NAME
when: manual
only:
- web
#
# Build the single archive image for stable versions
#
image:docs-stable:
stage: docker-stable
<<: *docker_build
variables:
NANOC_ENV: 'production'
IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
script:
- docker build --build-arg NANOC_ENV=${NANOC_ENV} --build-arg CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME} -t $IMAGE_NAME .
- docker push $IMAGE_NAME
# Only branches with versions like 10.4
only:
- /^\d{1,2}\.\d{1,2}$/
except:
- tags
#
# Build the multiple archives image
#
image:docs-archives:
stage: images
<<: *docker_build
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE:archives
script:
- docker build -t $IMAGE_NAME -f dockerfiles/Dockerfile.archives .
- docker push $IMAGE_NAME
when: manual
<<: *except_stable
#
# Build master containing all archives and latest docs
#
image:docs-latest:
stage: docker-stable
<<: *docker_build
variables:
NANOC_ENV: 'production'
IMAGE_NAME: $CI_REGISTRY_IMAGE:latest
script:
- docker build --build-arg NANOC_ENV=${NANOC_ENV} --build-arg CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME} -t $IMAGE_NAME .
- docker push $IMAGE_NAME
only:
- master
allow_failure: true
|