Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 194344c

Browse files
new release proc
1 parent 3b8748d commit 194344c

File tree

1 file changed

+60
-48
lines changed

1 file changed

+60
-48
lines changed

.circleci/config.yml

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
version: 2.1
22
orbs:
33
k8s: circleci/kubernetes@0.7.0
4-
s3: circleci/aws-s3@1.0.13
54
commands:
65
git_checkout_from_cache:
76
description: "Git checkout and save cache"
@@ -31,7 +30,6 @@ commands:
3130
key: source-v1-{{ .Branch }}-{{ .Revision }}
3231
paths:
3332
- ".git"
34-
3533
npm_install:
3634
description: "Install npm modules"
3735
steps:
@@ -48,48 +46,36 @@ commands:
4846
key: npm-v1-{{ checksum "package-lock.json" }}
4947
paths:
5048
- "node_modules"
51-
5249
build:
5350
description: "Build"
5451
steps:
5552
- run:
5653
name: "Compile project"
5754
command: npm run build
58-
59-
compress:
60-
description: "Compress"
55+
deploy:
56+
description: "Deploy to static branches"
57+
parameters:
58+
target_branch:
59+
type: string
6160
steps:
61+
- checkout
62+
- attach_workspace:
63+
at: dist/compressed
64+
- run:
65+
name: Tag build
66+
command: echo "<< parameters.target_branch >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > dist/compressed/version
6267
- run:
63-
name: "Compress"
68+
name: Install and configure dependencies
6469
command: |
65-
pushd dist/compressed/
66-
tar -cvf artifact.tar *
67-
mv artifact.tar ${OLDPWD}/
70+
sudo npm install -g gh-pages@2.0.1
71+
git config user.email "ci-build@binary.com"
72+
git config user.name "ci-build"
73+
- add_ssh_keys:
74+
fingerprints:
75+
- "6e:e8:9f:f9:7e:9f:50:a4:84:ac:15:b9:32:54:9f:71"
6876
- run:
69-
name: "Tag commit id as artifact identifer"
70-
command: echo "${CIRCLE_SHA1}" > artifact-info.txt
71-
72-
upload_artifact:
73-
description: "upload build artifact to s3 bucket"
74-
steps:
75-
- s3/copy:
76-
from: artifact.tar
77-
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
78-
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
79-
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
80-
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
81-
arguments: '--metadata "{\"x-amz-artifact-id\": \"${CIRCLE_SHA1}\" }"'
82-
83-
upload_checksum:
84-
description: "upload artifact checksum to s3"
85-
steps:
86-
- s3/copy:
87-
from: artifact-info.txt
88-
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
89-
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
90-
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
91-
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
92-
77+
name: Deploy docs to gh-pages branch
78+
command: gh-pages -d dist/compressed --branch << parameters.target_branch >> --message '[skip ci]'
9379
docker_build_push:
9480
description: "Build and Push image to docker hub"
9581
parameters:
@@ -145,26 +131,47 @@ commands:
145131
kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/<< parameters.k8s-deployment >> << parameters.k8s-deployment >>=${DOCKHUB_ORGANISATION}/binary-static-webtrader:<< parameters.docker_tag >>
146132
fi
147133
done
134+
notify_slack:
135+
description: "Notify slack"
136+
parameters:
137+
target:
138+
type: string
139+
steps:
140+
- slack/status:
141+
include_project_field: false
142+
failure_message: "<< parameters.target >> release failed for webtrader with version ``$(cat www/version)``"
143+
success_message: "<< parameters.target >> release succeeded for webtrader with version $(cat www/version)"
144+
webhook: ${SLACK_WEBHOOK}
148145
jobs:
149-
release_development:
146+
release_staging:
150147
docker:
151148
- image: circleci/node:12.13.0-stretch
152149
steps:
153150
- git_checkout_from_cache
154151
- npm_install
155152
- build
156-
- docker_build_push
157-
- k8s_deploy
153+
- deploy:
154+
target_branch: "staging"
155+
- notify_slack:
156+
target: "Staging"
158157
release_production:
159158
docker:
160159
- image: circleci/node:12.13.0-stretch
161160
steps:
162161
- git_checkout_from_cache
163162
- npm_install
164163
- build
165-
- compress
166-
- upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
167-
- upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint before actual deployment
164+
- deploy:
165+
target_branch: "production"
166+
- notify_slack:
167+
target: "Production"
168+
release_aws_production:
169+
docker:
170+
- image: circleci/node:12.13.0-stretch
171+
steps:
172+
- git_checkout_from_cache
173+
- npm_install
174+
- build
168175
- docker_build_push:
169176
docker_latest_tag: "latest"
170177
docker_tag: "${CIRCLE_SHA1}"
@@ -175,17 +182,22 @@ jobs:
175182
k8s-deployment: "webtrader-binary-com"
176183

177184
workflows:
178-
release_development:
179-
jobs:
180-
- release_development:
185+
release:
186+
jobs:
187+
- release_staging:
181188
filters:
182189
branches:
183-
only: /^development$/
184-
context: binary-frontend-artifact-upload
185-
release_production:
186-
jobs:
190+
only: /^master$/
187191
- release_production:
188192
filters:
189193
branches:
190-
only: /^master$/
194+
ignore: /.*/
195+
tags:
196+
only: /^production.*/
197+
- release_aws_production:
198+
filters:
199+
branches:
200+
ignore: /.*/
201+
tags:
202+
only: /^production.*/
191203
context: binary-frontend-artifact-upload

0 commit comments

Comments
 (0)