-
Notifications
You must be signed in to change notification settings - Fork 24
/
bitbucket-pipelines.yml
242 lines (201 loc) · 6.81 KB
/
bitbucket-pipelines.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
230
231
232
233
234
235
236
237
238
239
240
241
242
image: node:14.16.0
options:
size: 2x
definitions:
caches:
docker-cache: docker-cache
services:
docker:
memory: 7128
steps:
- step: &set-environment
name: Set Environment
artifacts:
- environment.sh
- step: &build
name: Installing & Build artifact
caches:
- node
script:
- source environment.sh
- yarn install
- yarn generate-assets
- yarn lint
- yarn typecheck
- yarn test
- yarn build
artifacts:
- .next/**
- step: &docker-build-publish
name: Docker - Build and Publish
services:
- docker
caches:
- docker-cache
script:
- source environment.sh
- >-
if [[ -f "docker-cache/cache.tar" ]]; then
docker load < docker-cache/cache.tar;
fi
- >-
docker build
-f Dockerfile_pipelines
-t $APP_NAME:latest
-t $APP_NAME:develop-latest
-t $APP_NAME:$DOCKER_ENV_TAG
.
- >-
docker save $(docker images -qa) > docker-cache/cache.tar;
- pipe: atlassian/aws-ecr-push-image:1.4.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: $APP_NAME
TAGS: >-
latest
develop-latest
$DOCKER_ENV_TAG
- step: &helm-build-deploy
name: Helm - Build and Deploy
image: alpine/helm:3.6.3
script:
- source environment.sh
- export CHART_FOLDER=deployment/app-chart
- helm lint $CHART_FOLDER
- >-
helm template $APP_NAME $CHART_FOLDER
--set image.tag=$DOCKER_ENV_TAG
--set environment.near_env=$NEAR_ENV
--set environment.near_contract_name=$NEAR_CONTRACT_NAME
--set environment.roketo_contract_name=$ROKETO_CONTRACT_NAME
--set environment.roketo_multicall_name=$ROKETO_MULTICALL_NAME
--set environment.api_url=$API_URL
--set environment.google_analytics_key=$GOOGLE_ANALYTICS_KEY
--set environment.log_rocket_app_id=$LOG_ROCKET_APP_ID
--set environment.dd_application_id=$DD_APPLICATION_ID
--set environment.dd_client_token=$DD_CLIENT_TOKEN
--set environment.dd_service=$DD_SERVICE
--set ingress.host=$K8S_INGRESS_HOST
> $APP_NAME-manifest.yml
- pipe: atlassian/aws-eks-kubectl-run:1.4.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
CLUSTER_NAME: $EKS_CLUSTER_NAME
KUBECTL_COMMAND: 'apply'
RESOURCE_PATH: '$APP_NAME-manifest.yml'
KUBECTL_ARGS:
- '--namespace=$DEPLOYMENT_NAMESPACE'
- step: &build-storybook
name: Build Storybook
caches:
- node
script:
- source environment.sh
- yarn install
- yarn lint
- yarn typecheck
- yarn build-storybook
artifacts:
- storybook-static/**
- step: &deploy-to-s3
name: Deploy to S3
deployment: development
script:
- source environment.sh
- pipe: atlassian/aws-s3-deploy:0.3.8
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: 'us-east-2'
S3_BUCKET: 'astro-storybook'
LOCAL_PATH: 'storybook-static'
ACL: 'public-read'
pipelines:
pull-requests:
'**':
- step:
<<: *set-environment
script:
- >-
echo export DOCKER_ENV_TAG=qa-$BITBUCKET_COMMIT >> environment.sh
- step: *build
custom:
qa:
- step:
<<: *set-environment
script:
- >-
echo export DOCKER_ENV_TAG=qa-$BITBUCKET_COMMIT >> environment.sh
- step: *build
- step: *docker-build-publish
- step:
<<: *helm-build-deploy
deployment: qa
test:
- step:
<<: *set-environment
script:
- >-
echo export DOCKER_ENV_TAG=test-$BITBUCKET_COMMIT >> environment.sh
- step: *build
- step: *docker-build-publish
- step:
<<: *helm-build-deploy
deployment: test
branches:
develop:
- step:
<<: *set-environment
script:
- >-
echo export DOCKER_ENV_TAG=develop-$BITBUCKET_COMMIT >> environment.sh
- step: *build
- step: *docker-build-publish
- step:
<<: *helm-build-deploy
deployment: development
- step: *build-storybook
- step:
<<: *deploy-to-s3
deployment: storybook
staging:
- step:
<<: *set-environment
script:
- >-
echo export DOCKER_ENV_TAG=staging-$BITBUCKET_COMMIT >> environment.sh
- echo export NEAR_ENV=$NEAR_ENV_STAGING >> environment.sh
- echo export API_URL=$API_URL_STAGING >> environment.sh
- echo export GOOGLE_ANALYTICS_KEY=$GOOGLE_ANALYTICS_KEY_STAGING >> environment.sh
- echo export LOG_ROCKET_APP_ID=$LOG_ROCKET_APP_ID_STAGING >> environment.sh
- echo export DD_APPLICATION_ID=$DD_APPLICATION_ID_STAGING >> environment.sh
- echo export DD_CLIENT_TOKEN=$DD_CLIENT_TOKEN_STAGING >> environment.sh
- echo export DD_SERVICE=$DD_SERVICE_STAGING >> environment.sh
- step: *build
- step: *docker-build-publish
- step:
<<: *helm-build-deploy
deployment: Staging
tags:
'*':
- step:
<<: *set-environment
script:
- >-
echo export DOCKER_ENV_TAG=$BITBUCKET_TAG >> environment.sh
- echo export NEAR_ENV=$NEAR_ENV_PROD >> environment.sh
- echo export API_URL=$API_URL_PROD >> environment.sh
- echo export GOOGLE_ANALYTICS_KEY=$GOOGLE_ANALYTICS_KEY_PROD >> environment.sh
- echo export LOG_ROCKET_APP_ID=$LOG_ROCKET_APP_ID_PROD >> environment.sh
- echo export DD_APPLICATION_ID=$DD_APPLICATION_ID_PROD >> environment.sh
- echo export DD_CLIENT_TOKEN=$DD_CLIENT_TOKEN_PROD >> environment.sh
- echo export DD_SERVICE=$DD_SERVICE_PROD >> environment.sh
- step: *build
- step: *docker-build-publish
- step:
<<: *helm-build-deploy
deployment: Production