11version : 2.1
22orbs :
33 k8s : circleci/kubernetes@0.7.0
4- s3 : circleci/aws-s3@1.0.13
54commands :
65 git_checkout_from_cache :
76 description : " Git checkout and save cache"
@@ -53,38 +52,31 @@ commands:
5352 - run :
5453 name : " yarn build"
5554 command : node_modules/gulp/bin/gulp.js build-min
56- compress :
57- description : " Compress"
55+ deploy :
56+ description : " Deploy to static branches"
57+ parameters :
58+ target_branch :
59+ type : string
5860 steps :
61+ - checkout
62+ - attach_workspace :
63+ at : www
5964 - run :
60- name : " Compress"
65+ name : Tag build
66+ command : echo "<< parameters.target_branch >> $(date)" > www/version
67+ - run :
68+ name : Install and configure dependencies
6169 command : |
62- pushd www/
63- tar -cvf artifact.tar *
64- 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+ - " c5:a7:d0:64:8d:7c:44:f7:6c:84:a9:b2:67:3e:9d:00"
6576 - run :
66- name : " Tag commit id as artifact identifer"
67- command : echo "${CIRCLE_SHA1}" > artifact-info.txt
68- upload_artifact :
69- description : " upload artifact to s3"
70- steps :
71- - s3/copy :
72- from : artifact.tar
73- to : ' s3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
74- aws-access-key-id : env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
75- aws-secret-access-key : env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
76- aws-region : env_CONTEXT_ARTIFACT_S3_AWS_REGION
77- arguments : ' --metadata "{\"x-amz-artifact-id\": \"${CIRCLE_SHA1}\" }"'
78- upload_checksum :
79- description : " upload artifact commit id to s3"
80- steps :
81- - s3/copy :
82- from : artifact-info.txt
83- to : ' s3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
84- aws-access-key-id : env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
85- aws-secret-access-key : env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
86- aws-region : env_CONTEXT_ARTIFACT_S3_AWS_REGION
87- docker :
77+ name : Deploy docs to gh-pages branch
78+ command : gh-pages -d www --branch << parameters.target_branch >> --message '[skip ci]'
79+ docker_build_push :
8880 description : " Build and Push image to docker hub"
8981 parameters :
9082 target :
@@ -130,7 +122,7 @@ commands:
130122 fi
131123 done
132124
133- npm_test :
125+ test :
134126 description : Run test
135127 steps :
136128 - run :
@@ -145,30 +137,35 @@ jobs:
145137 steps :
146138 - git_checkout_from_cache
147139 - npm_install
148- - npm_test
140+ - test
149141
150142 release_beta :
151143 docker :
152- - image : circleci/node:12.13 .0-stretch
144+ - image : circleci/node:8.10 .0-stretch
153145 steps :
154146 - git_checkout_from_cache
155147 - npm_install
156148 - build
157- - docker :
158- target : " beta"
159- - k8s_deploy :
160- target : " beta"
149+ - deploy :
150+ target_branch : " staging"
161151
162152 release_production :
153+ docker :
154+ - image : circleci/node:8.10.0-stretch
155+ steps :
156+ - git_checkout_from_cache
157+ - npm_install
158+ - build
159+ - deploy :
160+ target_branch : " production"
161+
162+ release_aws_production :
163163 docker :
164164 - image : circleci/node:12.13.0-stretch
165165 steps :
166166 - git_checkout_from_cache
167167 - npm_install
168168 - build
169- - compress
170- - upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
171- - upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint before actual deployment
172169 - docker :
173170 target : " production"
174171 - k8s_deploy :
@@ -181,12 +178,15 @@ workflows:
181178 release :
182179 jobs :
183180 - release_beta :
181+ filters :
182+ branches :
183+ only : /^master$/
184+ - release_production :
184185 filters :
185186 branches :
186187 ignore : /.*/
187188 tags :
188- only : /^beta.*/
189- context : binary-frontend-artifact-upload
189+ only : /^production.*/
190190 - release_production :
191191 filters :
192192 branches :
0 commit comments