11version : 2.1
22orbs :
334- 4+ 55commands :
66 git_checkout_from_cache :
77 description : " Git checkout and save cache"
@@ -31,7 +31,6 @@ commands:
3131 key : source-v1-{{ .Branch }}-{{ .Revision }}
3232 paths :
3333 - " .git"
34-
3534 npm_install :
3635 description : " Install npm modules"
3736 steps :
@@ -48,48 +47,36 @@ commands:
4847 key : npm-v1-{{ checksum "package-lock.json" }}
4948 paths :
5049 - " node_modules"
51-
5250 build :
5351 description : " Build"
5452 steps :
5553 - run :
5654 name : " Compile project"
5755 command : npm run build
58-
59- compress :
60- description : " Compress"
56+ deploy :
57+ description : " Deploy to static branches"
58+ parameters :
59+ target_branch :
60+ type : string
6161 steps :
62+ - checkout
63+ - attach_workspace :
64+ at : dist/compressed
65+ - run :
66+ name : Tag build
67+ command : echo "<< parameters.target_branch >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > dist/compressed/version
6268 - run :
63- name : " Compress "
69+ name : Install and configure dependencies
6470 command : |
65- pushd dist/compressed/
66- tar -cvf artifact.tar *
67- mv artifact.tar ${OLDPWD}/
71+ 72+ git config user.email "[email protected] " 73+ git config user.name "ci-build"
74+ - add_ssh_keys :
75+ fingerprints :
76+ - " 01:67:4a:6d:26:9c:70:c4:1a:60:91:88:d9:dd:f0:83"
6877 - 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-
78+ name : Deploy docs to gh-pages branch
79+ command : node ./node_modules/gh-pages/bin/gh-pages -d dist/compressed --branch << parameters.target_branch >> --message '[skip ci]'
9380 docker_build_push :
9481 description : " Build and Push image to docker hub"
9582 parameters :
@@ -145,26 +132,49 @@ commands:
145132 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 >>
146133 fi
147134 done
135+ notify_slack :
136+ description : " Notify slack"
137+ steps :
138+ - slack/status :
139+ include_project_field : false
140+ failure_message : " Release failed for webtrader with version *$(cat dist/compressed/version)*"
141+ success_message : " Release succeeded for webtrader with version *$(cat dist/compressed/version)*"
142+ webhook : ${SLACK_WEBHOOK}
148143jobs :
149- release_development :
144+ build :
145+ docker :
146+ - image : circleci/node:12.13.0-stretch
147+ steps :
148+ - git_checkout_from_cache
149+ - npm_install
150+ - build
151+ release_staging :
150152 docker :
151153 - image : circleci/node:12.13.0-stretch
152154 steps :
153155 - git_checkout_from_cache
154156 - npm_install
155157 - build
156- - docker_build_push
157- - k8s_deploy
158+ - deploy :
159+ target_branch : " staging"
160+ - notify_slack
158161 release_production :
159162 docker :
160163 - image : circleci/node:12.13.0-stretch
161164 steps :
162165 - git_checkout_from_cache
163166 - npm_install
164167 - 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
168+ - deploy :
169+ target_branch : " production"
170+ - notify_slack
171+ release_aws_production :
172+ docker :
173+ - image : circleci/node:12.13.0-stretch
174+ steps :
175+ - git_checkout_from_cache
176+ - npm_install
177+ - build
168178 - docker_build_push :
169179 docker_latest_tag : " latest"
170180 docker_tag : " ${CIRCLE_SHA1}"
@@ -175,17 +185,28 @@ jobs:
175185 k8s-deployment : " webtrader-binary-com"
176186
177187workflows :
178- release_development :
179- jobs :
180- - release_development :
188+ build :
189+ jobs :
190+ - build :
181191 filters :
182192 branches :
183- only : /^development$/
184- context : binary-frontend-artifact-upload
185- release_production :
186- jobs :
187- - release_production :
193+ ignore : /^master$/
194+ release :
195+ jobs :
196+ - release_staging :
188197 filters :
189198 branches :
190199 only : /^master$/
200+ - release_production :
201+ filters :
202+ branches :
203+ ignore : /.*/
204+ tags :
205+ only : /^production.*/
206+ - release_aws_production :
207+ filters :
208+ branches :
209+ ignore : /.*/
210+ tags :
211+ only : /^production.*/
191212 context : binary-frontend-artifact-upload
0 commit comments