-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.drone.yml
229 lines (214 loc) · 4.69 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
kind: secret
name: username
get:
path: caesar-team/data/registry
name: username
---
kind: secret
name: password
get:
path: caesar-team/data/registry
name: password
---
kind: secret
name: repository
get:
path: caesar-team/data/registry
name: repo-server
---
kind: secret
name: registry
get:
path: secret/data/registry
name: registry
---
kind: secret
name: develop_url
get:
path: secret/data/k8s-4xxi
name: develop_url
---
kind: secret
name: develop_token
get:
path: secret/data/k8s-4xxi
name: develop_token
---
kind: secret
name: develop_ca
get:
path: secret/data/k8s-4xxi
name: develop_ca
---
kind: secret
name: staging_url
get:
path: secret/data/k8s-4xxi
name: staging_url
---
kind: secret
name: staging_token
get:
path: secret/data/k8s-4xxi
name: staging_token
---
kind: secret
name: staging_ca
get:
path: secret/data/k8s-4xxi
name: staging_ca
---
kind: secret
name: notifications
get:
path: secret/data/notifications-4xxi
name: caesar-builds
---
kind: secret
name: notification_username
get:
path: secret/data/notifications-4xxi
name: username
---
kind: secret
name: notification_icon
get:
path: secret/data/notifications-4xxi
name: icon_url
---
kind: secret
name: dockerconfig
get:
path: secret/data/docker
name: config.json
---
kind: pipeline
type: docker
name: 4xxi
image_pull_secrets:
- dockerconfig
globals:
- &confNoSaveBuild
dockerfile: Dockerfile
repo: plugins/docker
tag: fourxxi
dry_run: true
daemon_off: false
- &confSaveBuild
dockerfile: Dockerfile
repo:
from_secret: repository
tag: ${DRONE_BRANCH}
username:
from_secret: username
password:
from_secret: password
- &stepCheckBuild
name: build test
image: plugins/docker
settings:
<<: *confNoSaveBuild
- &stepMainBuild
name: build
image: plugins/docker
settings:
<<: *confSaveBuild
- &stepTagBuild
image: plugins/docker
settings:
auto_tag: true
<<: *confSaveBuild
- &stepDevelopDeploy
name: deploy develop
image: sinlead/drone-kubectl
settings:
kubernetes_server:
from_secret: develop_url
kubernetes_token:
from_secret: develop_token
kubernetes_cert:
from_secret: develop_ca
environment:
CICD_GIT_COMMIT: ${DRONE_COMMIT}
CICD_GIT_BRANCH: ${DRONE_BRANCH}
commands:
- sed -i "s/\$CICD_GIT_BRANCH/$CICD_GIT_BRANCH/g" k8s/deployment.yaml
- sed -i "s/\$CICD_GIT_COMMIT/$CICD_GIT_COMMIT/g" k8s/deployment.yaml
- kubectl apply -f k8s/deployment.yaml
- &stepMasterDeploy
name: deploy staging
image: sinlead/drone-kubectl
settings:
kubernetes_server:
from_secret: staging_url
kubernetes_token:
from_secret: staging_token
kubernetes_cert:
from_secret: staging_ca
environment:
CICD_GIT_COMMIT: ${DRONE_COMMIT}
CICD_GIT_BRANCH: ${DRONE_BRANCH}
commands:
- sed -i "s/\$CICD_GIT_BRANCH/$CICD_GIT_BRANCH/g" k8s/deployment.yaml
- sed -i "s/\$CICD_GIT_COMMIT/$CICD_GIT_COMMIT/g" k8s/deployment.yaml
- kubectl apply -f k8s/deployment.yaml
- &stepNotifyToSlack
name: notify-to-slack
image: plugins/slack
pull: always
settings:
webhook:
from_secret: notifications
channel: caesar-builds
username:
from_secret: notification_username
icon_url:
from_secret: notification_icon
template: >
{{#success build.status}}
*Event*: `{{build.event}}` {{build.status}}
*Repository*: `{{repo.name}}` to `{{build.branch}}`
*Commit*: `{{build.commit}}`
*Info*: {{build.number}} build was started {{since build.created}} and executed for {{since build.started}}
<{{build.link}}|*Build link*>
{{else}}
*Event*: `{{build.event}}` {{build.status}}
*Repository*: `{{repo.name}}` to `{{build.branch}}`
*Commit*: `{{build.commit}}`
*Info*: {{build.number}} build was started {{since build.created}} and executed for {{since build.started}}
<{{build.link}}|*Build link*>
{{/success}}
steps:
- <<: *stepCheckBuild
when:
branch: [feature/*, hotfix/*]
event: [push]
- <<: *stepMainBuild
when:
branch: [develop, master]
event: [push]
- <<: *stepDevelopDeploy
when:
branch: [develop]
event: [push]
- name: build tag
<<: *stepTagBuild
when:
branch: [master]
event: [tag]
#- <<: *stepMasterDeploy
# when:
# branch: [ master ]
- <<: *stepNotifyToSlack
when:
status: [success, failure]
branch: [develop, master]
trigger:
branch:
- master
- develop
- feature/*
- hotfix/*
event:
- tag
- push