This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
/
.drone.yml
524 lines (495 loc) · 14.1 KB
/
.drone.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
---
kind: pipeline
type: kubernetes
name: pr build
trigger:
event:
- pull_request
steps:
- name: short circuit docs changes
image: docker:git
commands:
# If a change is entirely documentation, skip the expensive build & test steps.
# https://discourse.drone.io/t/how-to-exit-a-pipeline-early-without-failing/3951
- ./build.assets/drone/diff-is-all-docs.sh $DRONE_COMMIT_BEFORE..$DRONE_COMMIT_AFTER && exit 78 || exit 0
- name: fetch tags
image: docker:git
commands:
- git fetch --tags
- name: wait for docker
image: docker
commands:
- timeout 15s /bin/sh -c 'while [ ! -S /var/run/docker.sock ]; do sleep 1; done'
- docker version
volumes:
- name: dockersock
path: /var/run
- name: lint
image: docker:git
commands:
- apk add --no-cache make bash libc6-compat
- make -C build.assets golint
volumes:
- name: dockersock
path: /var/run
- name: assume AWS role
image: amazon/aws-cli
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_S3_RO_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_S3_RO_SECRET_ACCESS_KEY
AWS_ROLE:
from_secret: AWS_S3_RO_ROLE
volumes:
- name: awsconfig
path: /root/.aws
commands:
- aws sts get-caller-identity
- |-
printf "[default]\naws_access_key_id = %s\naws_secret_access_key = %s\naws_session_token = %s\n" \
$(aws sts assume-role \
--role-arn "$AWS_ROLE" \
--role-session-name $(echo "drone-${DRONE_REPO}-${DRONE_BUILD_NUMBER}" | sed "s|/|-|g") \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text) \
> /root/.aws/credentials
- unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
- aws sts get-caller-identity --profile default
- name: build
image: docker:git
commands:
- apk add --no-cache make bash libc6-compat aws-cli fakeroot
- make -C e production telekube opscenter
- make build-tsh
volumes:
- name: awsconfig
path: /root/.aws
- name: dockersock
path: /var/run
- name: unit test
image: docker:git
commands:
- apk add --no-cache make bash libc6-compat
- make -C e test
- make test
volumes:
- name: dockersock
path: /var/run
- name: build robotest images
image: docker:git
commands:
- apk add --no-cache make bash libc6-compat
- make -C e/assets/robotest images
volumes:
- name: dockersock
path: /var/run
- name: run robotest
image: docker:git
environment:
GCP_ROBOTEST_CREDENTIALS:
from_secret: GCP_ROBOTEST_CREDENTIALS
# These files need to be in a volume that the docker service has access to
# We choose /tmp to accommodate https://github.com/gravitational/robotest/blob/3774f8641439b19c4e0e598db8f87c52ea0e4817/docker/suite/run_suite.sh#L106
SSH_KEY: /tmp/secrets/robotest
SSH_PUB: /tmp/secrets/robotest.pub
GOOGLE_APPLICATION_CREDENTIALS: /tmp/secrets/gcp.json
commands:
- apk add --no-cache make bash
- mkdir -p $(dirname $SSH_KEY)
- ssh-keygen -t ed25519 -N '' -f $SSH_KEY
- echo "$GCP_ROBOTEST_CREDENTIALS" > $GOOGLE_APPLICATION_CREDENTIALS
- make -C e robotest-run
volumes:
- name: dockersock
path: /var/run
- name: dockertmp
path: /tmp
services:
- name: run docker daemon
image: docker:20.10.6-dind
privileged: true
volumes:
- name: dockersock
path: /var/run
- name: dockertmp
path: /tmp
volumes:
- name: awsconfig
temp: {}
- name: dockersock
temp: {}
- name: dockertmp
temp: {}
---
kind: pipeline
type: kubernetes
name: post-merge build
trigger:
event:
- push
branch:
- master
steps:
- name: short circuit docs changes
image: docker:git
commands:
# If a change is entirely documentation, skip the expensive build & test steps.
# https://discourse.drone.io/t/how-to-exit-a-pipeline-early-without-failing/3951
- ./build.assets/drone/diff-is-all-docs.sh $DRONE_COMMIT_BEFORE..$DRONE_COMMIT_AFTER && exit 78 || exit 0
- name: fetch tags
image: docker:git
commands:
- git fetch --tags
- name: wait for docker
image: docker
commands:
- timeout 15s /bin/sh -c 'while [ ! -S /var/run/docker.sock ]; do sleep 1; done'
- docker version
volumes:
- name: dockersock
path: /var/run
- name: assume AWS role
image: amazon/aws-cli
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_S3_RO_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_S3_RO_SECRET_ACCESS_KEY
AWS_ROLE:
from_secret: AWS_S3_RO_ROLE
volumes:
- name: awsconfig
path: /root/.aws
commands:
- aws sts get-caller-identity
- |-
printf "[default]\naws_access_key_id = %s\naws_secret_access_key = %s\naws_session_token = %s\n" \
$(aws sts assume-role \
--role-arn "$AWS_ROLE" \
--role-session-name $(echo "drone-${DRONE_REPO}-${DRONE_BUILD_NUMBER}" | sed "s|/|-|g") \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text) \
> /root/.aws/credentials
- unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
- aws sts get-caller-identity --profile default
- name: build
image: docker:git
commands:
- apk add --no-cache make bash libc6-compat aws-cli fakeroot
- make -C e production telekube opscenter
- make build-tsh
volumes:
- name: awsconfig
path: /root/.aws
- name: dockersock
path: /var/run
- name: build robotest images
image: docker:git
commands:
- apk add --no-cache make bash libc6-compat
- export ROBOTEST_CONFIG=nightly
- make -C e/assets/robotest images
volumes:
- name: dockersock
path: /var/run
- name: run robotest
image: docker:git
environment:
GCP_ROBOTEST_CREDENTIALS:
from_secret: GCP_ROBOTEST_CREDENTIALS
# These files need to be in a volume that the docker service has access to
# We choose /tmp to accommodate https://github.com/gravitational/robotest/blob/3774f8641439b19c4e0e598db8f87c52ea0e4817/docker/suite/run_suite.sh#L106
SSH_KEY: /tmp/secrets/robotest
SSH_PUB: /tmp/secrets/robotest.pub
GOOGLE_APPLICATION_CREDENTIALS: /tmp/secrets/gcp.json
commands:
- apk add --no-cache make bash
- mkdir -p $(dirname $SSH_KEY)
- ssh-keygen -t ed25519 -N '' -f $SSH_KEY
- echo "$GCP_ROBOTEST_CREDENTIALS" > $GOOGLE_APPLICATION_CREDENTIALS
- export ROBOTEST_CONFIG=nightly
- make -C e robotest-run
volumes:
- name: dockersock
path: /var/run
- name: dockertmp
path: /tmp
services:
- name: run docker daemon
image: docker:20.10.6-dind
privileged: true
volumes:
- name: dockersock
path: /var/run
- name: dockertmp
path: /tmp
volumes:
- name: awsconfig
temp: {}
- name: dockersock
temp: {}
- name: dockertmp
temp: {}
---
kind: pipeline
type: kubernetes
name: pr docs
trigger:
event:
- pull_request
branch:
- master
steps:
- name: wait for docker
image: docker
commands:
- timeout 15s /bin/sh -c 'while [ ! -S /var/run/docker.sock ]; do sleep 1; done'
- docker version
volumes:
- name: dockersock
path: /var/run
- name: build buildbox
image: docker:git
commands:
- apk add --no-cache make
- make -C docs bbox
volumes:
- name: dockersock
path: /var/run
- name: build
image: docker:git
commands:
- apk add --no-cache make
- make -C docs docs
volumes:
- name: dockersock
path: /var/run
- name: lint
image: docker:git
commands:
- apk add --no-cache make
- make -C docs lint
volumes:
- name: dockersock
path: /var/run
services:
- name: run docker daemon
image: docker:20.10.6-dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
---
kind: pipeline
type: kubernetes
name: tag
# This pipeline generates placeholder builds that Drone CI promotions can reference.
# See https://docs.drone.io/promote/
#
# This is useful, because it allows re-running release steps without re-pushing
# tags to the repo, in case of faulty infrastructure. We don't ever want to overwrite
# released tags. It'd be good to verify that the tags are signed and not already
# present in this build. -- walt 2021-03
trigger:
event:
- tag
steps:
- name: fetch tags
image: docker:git
commands:
- git fetch --tags
- name: check version
image: docker:git
commands:
- apk add --no-cache make bash
- make get-version
---
kind: pipeline
type: kubernetes
name: publish-dependencies
trigger:
event:
- promote
target:
- release
- publish-dependencies
steps:
- name: fetch tags
image: docker:git
commands:
- git fetch --tags
- name: wait for docker
image: docker
commands:
- timeout 15s /bin/sh -c 'while [ ! -S /var/run/docker.sock ]; do sleep 1; done'
- docker version
volumes:
- name: dockersock
path: /var/run
- name: assume AWS role
image: amazon/aws-cli
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_S3_RO_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_S3_RO_SECRET_ACCESS_KEY
AWS_ROLE:
from_secret: AWS_S3_RO_ROLE
volumes:
- name: awsconfig
path: /root/.aws
commands:
- aws sts get-caller-identity
- |-
printf "[default]\naws_access_key_id = %s\naws_secret_access_key = %s\naws_session_token = %s\n" \
$(aws sts assume-role \
--role-arn "$AWS_ROLE" \
--role-session-name $(echo "drone-${DRONE_REPO}-${DRONE_BUILD_NUMBER}" | sed "s|/|-|g") \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text) \
> /root/.aws/credentials
- unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
- aws sts get-caller-identity --profile default
- name: build
image: docker:git
commands:
- apk add --no-cache make bash libc6-compat aws-cli fakeroot
- make -C e production
volumes:
- name: awsconfig
path: /root/.aws
- name: dockersock
path: /var/run
- name: assume publish AWS role
image: amazon/aws-cli
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_S3_RW_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_S3_RW_SECRET_ACCESS_KEY
AWS_ROLE:
from_secret: AWS_S3_RW_ROLE
volumes:
- name: awsconfig
path: /root/.aws
commands:
- aws sts get-caller-identity
- |-
printf "[default]\naws_access_key_id = %s\naws_secret_access_key = %s\naws_session_token = %s\n" \
$(aws sts assume-role \
--role-arn "$AWS_ROLE" \
--role-session-name $(echo "drone-${DRONE_REPO}-${DRONE_BUILD_NUMBER}" | sed "s|/|-|g") \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text) \
> /root/.aws/credentials
- unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
- aws sts get-caller-identity --profile default
- name: publish dependencies
image: docker:git
environment:
TELE_COPY_TO_USER:
from_secret: QUAY_IO_SCAN_UPLOAD_USER
TELE_COPY_TO_PASS:
from_secret: QUAY_IO_SCAN_UPLOAD_TOKEN
commands:
- apk add --no-cache make bash libc6-compat aws-cli
- make -C e publish
volumes:
- name: awsconfig
path: /root/.aws
- name: dockersock
path: /var/run
services:
- name: run docker daemon
image: docker:20.10.6-dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: awsconfig
temp: {}
- name: dockersock
temp: {}
---
kind: pipeline
type: kubernetes
name: publish-enterprise
trigger:
event:
- promote
target:
- release
- publish-enterprise
steps:
- name: fetch tags
image: docker:git
commands:
- git fetch --tags
- name: wait for docker
image: docker
commands:
- timeout 15s /bin/sh -c 'while [ ! -S /var/run/docker.sock ]; do sleep 1; done'
- docker version
volumes:
- name: dockersock
path: /var/run
- name: assume AWS role
image: amazon/aws-cli
environment:
AWS_ACCESS_KEY_ID:
from_secret: AWS_S3_RO_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_S3_RO_SECRET_ACCESS_KEY
AWS_ROLE:
from_secret: AWS_S3_RO_ROLE
volumes:
- name: awsconfig
path: /root/.aws
commands:
- aws sts get-caller-identity
- |-
printf "[default]\naws_access_key_id = %s\naws_secret_access_key = %s\naws_session_token = %s\n" \
$(aws sts assume-role \
--role-arn "$AWS_ROLE" \
--role-session-name $(echo "drone-${DRONE_REPO}-${DRONE_BUILD_NUMBER}" | sed "s|/|-|g") \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text) \
> /root/.aws/credentials
- unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
- aws sts get-caller-identity --profile default
- name: publish on linux
image: docker:git
environment:
TELE_KEY:
from_secret: DISTRIBUTION_OPSCENTER_TOKEN
commands:
- apk add --no-cache make bash libc6-compat aws-cli fakeroot
- make -C e production
- e/build/current/tele login --hub get.gravitational.io --token $TELE_KEY
- make -C e telekube opscenter publish-telekube publish-artifacts
volumes:
- name: awsconfig
path: /root/.aws
- name: dockersock
path: /var/run
services:
- name: run docker daemon
image: docker:20.10.6-dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
- name: awsconfig
temp: {}
---
kind: signature
hmac: 65a5d59e47ea7a322188e7e3a6a98a079e06943733643b39ad5083e2bab12b92
...