-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy path.drone.yml
More file actions
144 lines (134 loc) · 3.89 KB
/
.drone.yml
File metadata and controls
144 lines (134 loc) · 3.89 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
---
kind: pipeline
type: kubernetes
name: production-build
trigger:
branch:
- main
- DOP-5575
event:
- push
- tag
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
---
depends_on: ['production-build']
kind: pipeline
type: kubernetes
name: production-deploy
trigger:
branch:
- main
- DOP-5575
event:
- push
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
---
# 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