11version : 2.1
22orbs :
33 k8s : circleci/kubernetes@0.7.0
4+ s3 : circleci/aws-s3@1.0.13
45commands :
56 git_checkout_from_cache :
67 description : " Git checkout and save cache"
@@ -11,8 +12,8 @@ commands:
1112 - source-v1-{{ .Branch }}-{{ .Revision }}
1213 - source-v1-{{ .Branch }}-
1314 - source-v1-
14- - run :
15- name : Fetch git tags
15+ - run :
16+ name : Fetch git tags
1617 command : |
1718 mkdir -p ~/.ssh
1819 echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== ' >> ~/.ssh/known_hosts
@@ -23,7 +24,7 @@ commands:
2324 fi
2425 - checkout
2526 - run :
26- name : Compress git objects
27+ name : Compress git objects
2728 command : git gc
2829 - save_cache :
2930 name : Git save cache
@@ -46,28 +47,57 @@ commands:
4647 key : npm-v1-{{ checksum "package.json" }}
4748 paths :
4849 - " node_modules"
49-
5050 build :
5151 description : " Build"
5252 steps :
5353 - run :
5454 name : " yarn build"
5555 command : node_modules/gulp/bin/gulp.js build-min
56-
56+ compress :
57+ description : " Compress"
58+ steps :
59+ - run :
60+ name : " Compress"
61+ command : |
62+ pushd www/
63+ tar -cvf artifact.tar *
64+ mv artifact.tar ${OLDPWD}/
65+ - 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
5787 docker :
5888 description : " Build and Push image to docker hub"
5989 parameters :
6090 target :
6191 type : string
6292 steps :
6393 - setup_remote_docker
64- - run :
94+ - run :
6595 name : Building docker image for << parameters.target >>
6696 command : |
6797 build_tag="${CIRCLE_SHA1}"
6898 [ "<< parameters.target >>" == "beta" ] && build_tag="beta-${CIRCLE_SHA1}"
6999 docker build -t ${DOCKHUB_ORGANISATION}/binary-static-bot:${build_tag} .
70- - run :
100+ - run :
71101 name : Pushing Image to docker hub
72102 command : |
73103 build_tag="${CIRCLE_SHA1}"
@@ -81,7 +111,7 @@ commands:
81111 type : string
82112 steps :
83113 - k8s/install-kubectl
84- - run :
114+ - run :
85115 name : Deploying to k8s cluster for service binary-bot-beta
86116 command : |
87117 build_tag="${CIRCLE_SHA1}"
@@ -118,14 +148,17 @@ jobs:
118148 target : " beta"
119149 - k8s_deploy :
120150 target : " beta"
121-
151+
122152 release_production :
123153 docker :
124154 - image : circleci/node:12.13.0-stretch
125155 steps :
126156 - git_checkout_from_cache
127157 - npm_install
128158 - build
159+ - compress
160+ - upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
161+ - upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint before actual deployment
129162 - docker :
130163 target : " production"
131164 - k8s_deploy :
@@ -135,7 +168,6 @@ workflows:
135168 test :
136169 jobs :
137170 - test
138-
139171 release :
140172 jobs :
141173 - release_beta :
@@ -150,4 +182,4 @@ workflows:
150182 ignore : /.*/
151183 tags :
152184 only : /^production.*/
153-
185+ context : binary-frontend-artifact-upload
0 commit comments