-
Notifications
You must be signed in to change notification settings - Fork 25
/
.drone.yml
136 lines (123 loc) · 3.95 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
kind: pipeline
name: "Push"
concurrency:
limit: 2
steps:
- name: "Test & Build"
image: node:10.11
commands:
- yarn
- yarn build
- yarn test
- name: "Stage with mock server"
image: alpine/git
environment:
PRIVATE_KEY:
from_secret: mock_deploy_key_b64
commands:
- echo "$PRIVATE_KEY" | base64 -d > id_rsa
- chmod 0600 id_rsa
- cd build/
- echo "window.env={authUrl:'http://api-v2.mock.openware.work/api/v2/barong',tablePageLimit:50,msAlertDisplayTime:'5000'};" > env.js
- cat env.js
- cd /drone/src/
- cat build/env.js
- cd build
- mkdir tower
- mv static tower && mv env.js tower && mv commons.js* tower
- cd ..
- scp -r -i id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null build mock@mock.openware.work:/home/mock/builds/${DRONE_COMMIT_SHA:0:7}
- echo "http://${DRONE_COMMIT_SHA:0:7}.mock.openware.work/tower"
- name: "Notify staging"
image: plugins/slack
settings:
webhook:
from_secret: baseapp_slack_webhook
channel:
from_secret: baseapp_slack_channel
template: >
{{#success build.status}}
[SUCCESS] (Base Application) Branch {{ build.branch }} by {{ build.author }} staging has succeeded!
Visit http://{{ truncate build.commit 7 }}.mock.openware.work to check it out!
{{else}}
[FAILURE] Branch {{ build.branch }} by {{ build.author }} staging has failed!
{{/success}}
Check the build info here: {{ build.link }}
when:
status: [success, failure]
trigger:
event:
- push
branch:
exclude:
- master
- obfuscated-*
---
kind: pipeline
name: "Deploy"
concurrency:
limit: 2
steps:
- name: "Bump & Tag"
image: node:10.11
environment:
GITHUB_API_KEY:
from_secret: kite_bot_key
commands:
- set -x
- git config --global user.name "Kite Bot"
- git config --global user.email "kite-bot@heliostech.fr"
- git remote add authenticated-origin https://kite-bot:$GITHUB_API_KEY@github.com/${DRONE_REPO}
- git fetch authenticated-origin
- yarn config set version-git-message "[ci Skip] Bump %s"
- yarn config set version-tag-prefix ""
- git_msg=$(git log -n1 --pretty=oneline)
- patch_level=$( (echo $git_msg | grep -q MAJOR-BUMP && echo major) || (echo $git_msg | grep -q MINOR-BUMP && echo minor) || echo patch)
- yarn version --"$patch_level" -y
- git push authenticated-origin HEAD:master
- git push authenticated-origin --tags
- git describe --tags $(git rev-list --tags --max-count=1) > .tags
- name: "Build"
image: node:10.11
commands:
- npm -g install yarn
- yarn install
- yarn build
- name: "Build container"
image: plugins/gcr
settings:
repo: gcr.io/openware-production/tower
json_key:
from_secret: openware_gcp_creds_base64
- name: "Redeploy on devkube"
image: rubykube/microkube:0.2.0
environment:
WEBHOOK_JWT_SECRET:
from_secret: devkube_webhook_secret
commands:
- export latest_image=gcr.io/openware-production/tower:$(cat .tags)
- cd /home/app
- bundle exec rake payload:send[tower,$latest_image,http://www.devkube.com:1337]
- name: "Notify about redeployment on devkube"
image: plugins/slack
settings:
webhook:
from_secret: baseapp_slack_webhook
channel:
from_secret: baseapp_slack_channel
template: >
{{#success build.status}}
[SUCCESS] (Base Application) Master branch build by {{ build.author }} has succeeded!
Version is {{ build.tag }}
Visit http://www.devkube.com to check it out!
{{else}}
[FAILURE] Master branch build by {{ build.author }} has failed!
{{/success}}
Check the build info here: {{ build.link }}
when:
status: [success, failure]
trigger:
branch:
- master
event:
- push