-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy path.drone.yml
More file actions
192 lines (180 loc) · 5.7 KB
/
Copy path.drone.yml
File metadata and controls
192 lines (180 loc) · 5.7 KB
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
---
kind: pipeline
type: kubernetes
name: production-build
trigger:
branch:
- main
- DOP-5575
event:
- push
- tag
paths:
include:
- platform/tools/cdnLogParser/**
- .drone.yml
steps:
# Builds and publishes Docker image for production
- name: publish-production
image: plugins/kaniko-ecr
settings:
create_repository: true
registry: 795250896452.dkr.ecr.us-east-1.amazonaws.com
repo: docs/${DRONE_REPO_NAME}
tags:
- git-${DRONE_COMMIT_SHA:0:7}
- latest
context: platform/tools/cdnLogParser
dockerfile: platform/tools/cdnLogParser/Dockerfile
access_key:
from_secret: ecr_access_key
secret_key:
from_secret: ecr_secret_key
# A build failure skips the production-deploy pipeline entirely, so that
# pipeline's notify-slack step never runs. Notify here on failure only;
# a successful build is reported by the deploy pipeline.
- name: notify-slack-build-failure
image: alpine/curl
environment:
SLACK_WEBHOOK:
from_secret: cdn_log_parser_slack_webhook_url
commands:
- |
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\": \"❌ *CDN Log Parser Build Failed*\n*Repo:* $DRONE_REPO_NAME\n*Branch:* $DRONE_BRANCH\n*Commit:* ${DRONE_COMMIT_SHA:0:7}\n*Author:* $DRONE_COMMIT_AUTHOR\n*Build:* <$DRONE_BUILD_LINK|#$DRONE_BUILD_NUMBER>\"}" \
"$SLACK_WEBHOOK"
when:
status:
- failure
---
depends_on: ['production-build']
kind: pipeline
type: kubernetes
name: production-deploy
trigger:
branch:
- main
- DOP-5575
event:
- push
paths:
include:
- platform/tools/cdnLogParser/**
- .drone.yml
steps:
# Deploys docker image to production
- name: deploy-production
image: quay.io/mongodb/drone-helm:v3
settings:
chart: mongodb/cronjobs
chart_version: 1.21.2
add_repos: [mongodb=https://10gen.github.io/helm-charts]
namespace: docs
release: ${DRONE_REPO_NAME}
values: image.tag=git-${DRONE_COMMIT_SHA:0:7},image.repository=795250896452.dkr.ecr.us-east-1.amazonaws.com/docs/${DRONE_REPO_NAME}
values_files: ['platform/tools/cdnLogParser/cronjobs.yml']
api_server: https://api.prod.corp.mongodb.com
kubernetes_token:
from_secret: prod_kubernetes_token
# Notify Slack of build/deploy status so failures are not silent.
# A stale MongoDB credential once broke the CDN log parser cron for
# months without any alert because this pipeline had no notification.
- name: notify-slack
image: alpine/curl
environment:
SLACK_WEBHOOK:
from_secret: cdn_log_parser_slack_webhook_url
commands:
- |
if [ "$DRONE_BUILD_STATUS" = "success" ]; then
STATUS_MSG="✅ *CDN Log Parser Deploy Succeeded*"
else
STATUS_MSG="❌ *CDN Log Parser Deploy Failed*"
fi
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\": \"$STATUS_MSG\n*Repo:* $DRONE_REPO_NAME\n*Branch:* $DRONE_BRANCH\n*Commit:* ${DRONE_COMMIT_SHA:0:7}\n*Author:* $DRONE_COMMIT_AUTHOR\n*Build:* <$DRONE_BUILD_LINK|#$DRONE_BUILD_NUMBER>\"}" \
"$SLACK_WEBHOOK"
when:
status:
- success
- failure
---
# Pipeline for OpenAPI test suite cronjob
# Combined into a single pipeline so paths trigger applies to all steps
kind: pipeline
type: kubernetes
name: openapi-tests
trigger:
branch:
- main
event:
- push
- pull_request
paths:
- code-example-tests/openapi/**
steps:
# Run tests to ensure they pass before building
- name: test
image: node:20-alpine
commands:
- cd code-example-tests/openapi
- npm ci
- npm test
# Build and publish Docker image for production (only on push to main)
- name: publish-production
image: plugins/kaniko-ecr
settings:
create_repository: true
registry: 795250896452.dkr.ecr.us-east-1.amazonaws.com
repo: docs/openapi-tests
context: code-example-tests/openapi
dockerfile: code-example-tests/openapi/Dockerfile
tags:
- git-${DRONE_COMMIT_SHA:0:7}
- latest
access_key:
from_secret: ecr_access_key
secret_key:
from_secret: ecr_secret_key
when:
event:
- push
# Deploy cronjob to production using Helm (only on push to main)
- name: deploy-production
image: quay.io/mongodb/drone-helm:v3
settings:
chart: mongodb/cronjobs
chart_version: 1.21.2
add_repos: [mongodb=https://10gen.github.io/helm-charts]
namespace: docs
release: openapi-tests
values: image.tag=git-${DRONE_COMMIT_SHA:0:7},image.repository=795250896452.dkr.ecr.us-east-1.amazonaws.com/docs/openapi-tests
values_files: ['code-example-tests/openapi/cronjobs.yml']
api_server: https://api.prod.corp.mongodb.com
kubernetes_token:
from_secret: prod_kubernetes_token
when:
event:
- push
# Notify Slack of build/deploy status (only on push to main)
- name: notify-slack
image: alpine/curl
environment:
SLACK_WEBHOOK:
from_secret: slack_webhook_url
commands:
- |
if [ "$DRONE_BUILD_STATUS" = "success" ]; then
STATUS_MSG="✅ *OpenAPI Tests Deploy Succeeded*"
else
STATUS_MSG="❌ *OpenAPI Tests Deploy Failed*"
fi
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\": \"$STATUS_MSG\n*Repo:* $DRONE_REPO_NAME\n*Branch:* $DRONE_BRANCH\n*Commit:* ${DRONE_COMMIT_SHA:0:7}\n*Author:* $DRONE_COMMIT_AUTHOR\n*Build:* <$DRONE_BUILD_LINK|#$DRONE_BUILD_NUMBER>\"}" \
"$SLACK_WEBHOOK"
when:
event:
- push
status:
- success
- failure