-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.yml
198 lines (177 loc) · 4.56 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
---
.add_ssh: &add_ssh |
mkdir ~/.ssh
echo $SSH_KEY > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
.doc_git: &doc_git |
VERSION=$(git describe --abbrev=0 --tag | tr -d '\n')
git clone $DOC_REPOSITORY_URL doc-git
rm -rf doc-git/doc/
mv doc/ doc-git/
cd doc-git
git add .
git commit -m "Add doc $VERSION"
git tag $VERSION
git log
git push
git push origin --tags
.cache_elixir:
- &restore_cache_elixir
image: minio/mc
commands:
- mc config host add s3 $ENDPOINT $ACCESS_KEY $SECRET_KEY
- MD5=$(md5sum mix.lock | sed 's/[ ]*mix.lock//g')
- |
if mc ls s3/mspr-billing-api/dependancies | grep $MD5
then
mc cp s3/mspr-billing-api/dependancies/$VERSION-$MD5.tar.gz ./
mkdir ./deps
tar xvf ./$VERSION-$MD5.tar.gz -C ./
fi
environment:
VERSION: v1
ENDPOINT:
from_secret: ENDPOINT_S3
ACCESS_KEY:
from_secret: ACCESS_KEY_S3
SECRET_KEY:
from_secret: SECRET_KEY_S3
- &setup_deps_elixir
image: elixir
commands:
- mix local.hex --force
- mix local.rebar --force
- mix deps.get
- mix deps.compile
- &rebuild_cache_elixir
image: minio/mc
commands:
- mc config host add s3 $ENDPOINT $ACCESS_KEY $SECRET_KEY
- MD5=$(md5sum mix.lock | sed 's/[ ]*mix.lock//g')
- tar cvf $VERSION-$MD5.tar.gz deps/
- mc cp ./$VERSION-$MD5.tar.gz s3/mspr-billing-api/dependancies/
environment:
VERSION: v1
ENDPOINT:
from_secret: ENDPOINT_S3
ACCESS_KEY:
from_secret: ACCESS_KEY_S3
SECRET_KEY:
from_secret: SECRET_KEY_S3
kind: pipeline
type: kubernetes
name: priority
steps:
- name: Restore cache
<<: *restore_cache_elixir
- name: Setup dependancies
<<: *setup_deps_elixir
depends_on:
- Restore cache
- name: Rebuild cache
<<: *rebuild_cache_elixir
depends_on:
- Setup dependancies
- name: Tests
image: elixir
commands:
- git fetch --tags
- mix local.hex --force
- mix local.rebar --force
- mix coveralls.post --token $COVERALLS_TOKEN --branch "$DRONE_BRANCH" --name "CI" --committer "$DRONE_COMMIT_AUTHOR" --sha "$DRONE_COMMIT_SHA" --message "$DRONE_COMMIT_MESSAGE"
environment:
MIX_ENV: test
COVERALLS_TOKEN:
from_secret: COVERALLS_TOKEN
depends_on:
- Rebuild cache
- name: Semantical Versionning
image: node:12
commands:
- npx -p @semantic-release/commit-analyzer -p @semantic-release/release-notes-generator -p @semantic-release/github -p @semantic-release/changelog -p @semantic-release/git -p semantic-release semantic-release
environment:
GITHUB_TOKEN:
from_secret: github_token
depends_on:
- Tests
when:
branch:
- master
event: push
- name: Generate release
image: elixir
commands:
- git fetch --tags
- SECRET_KEY_BASE=$(elixir -e ":crypto.strong_rand_bytes(48) |> Base.encode64 |> IO.puts")
- sed "s|SECRET+KEY+BASE|$SECRET_KEY_BASE|" config/prod.secret.exs.sample >config/prod.secret.exs
- mix local.hex --force
- mix local.rebar --force
- MIX_ENV=prod mix release app --path=build
depends_on:
- Tests
when:
event: tag
- name: docker
image: banzaicloud/drone-kaniko
settings:
email: louis.epsi.perdereau@gmail.com
dockerfile: ./Dockerfile
registry: docker.pkg.github.com
repo: lperdereau/mspr-billing-api/billing-api
username:
from_secret: github_username
password:
from_secret: github_token
tags:
- ${DRONE_TAG}
- latest
depends_on:
- Generate release
when:
event: tag
- name: rollout
image: pabloclsn/kubectl-docker:latest
commands:
- echo $KUBE_CONFIG > ~/.kube/config
- kubectl rollout restart deployment/billing-deployment -n prod-mspr-ci
environment:
KUBE_CONFIG:
from_secret: KUBE_CONFIG
depends_on: [docker]
when:
event: tag
- name: Documentation
image: elixir
commands:
- *add_ssh
- git fetch --tags
- mix local.hex --force
- mix deps.get
- ./docs.sh
- *doc_git
environment:
DOC_REPOSITORY_URL:
from_secret: DOC_REPOSITORY_URL
SSH_KEY:
from_secret: DOC_SSH_KEY
depends_on:
- rollout
when:
event: tag
trigger:
event:
exclude:
- cron
---
kind: pipeline
type: kubernetes
name: smokeTestHour
steps:
- name: Smoke test
image: cypress/included:3.8.3
commands:
- cypress run --headless --spec cypress/integration/smokeTest.spec.js --config baseUrl="https://billing.louisperdereau.fr"
trigger:
event:
- cron