1
1
version : 2.1
2
2
orbs :
3
3
k8s : circleci/kubernetes@0.7.0
4
- s3 : circleci/aws-s3@1.0.13
4
+ slack : circleci/slack@3.4.2
5
5
commands :
6
6
git_checkout_from_cache :
7
7
description : " Git checkout and save cache"
@@ -39,7 +39,7 @@ commands:
39
39
command : |
40
40
sudo apt-get update && sudo apt-get install -y ruby-full
41
41
sudo gem install sass
42
- npm_install_from_cache :
42
+ npm_install :
43
43
description : " npm install and save cache"
44
44
steps :
45
45
- restore_cache :
@@ -55,54 +55,44 @@ commands:
55
55
name : Save npm cache
56
56
paths :
57
57
- " node_modules"
58
- npm_build :
58
+ build :
59
59
description : " Grunt build the project"
60
60
steps :
61
61
- run :
62
62
name : " Build binary-style"
63
63
command : npm run build
64
- compress :
65
- description : " Compress"
64
+ deploy :
65
+ description : " Deploy to static branches"
66
+ parameters :
67
+ target_branch :
68
+ type : string
66
69
steps :
70
+ - checkout
71
+ - attach_workspace :
72
+ at : dist
73
+ - run :
74
+ name : Tag build
75
+ command : echo "<< parameters.target_branch >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > dist/version
67
76
- run :
68
- name : " Compress "
77
+ name : Install and configure dependencies
69
78
command : |
70
- pushd dist/
71
- tar -cvf artifact.tar *
72
- mv artifact.tar ${OLDPWD}/
79
+ sudo npm install -g gh-pages@2.0.1
80
+ git config user.email "ci-build@binary.com"
81
+ git config user.name "ci-build"
82
+ - add_ssh_keys :
83
+ fingerprints :
84
+ - " 01:67:4a:6d:26:9c:70:c4:1a:60:91:88:d9:dd:f0:83"
73
85
- run :
74
- name : " Tag commit id as artifact identifer"
75
- command : echo "${CIRCLE_SHA1}" > artifact-info.txt
76
- upload_artifact :
77
- description : " upload artifact to s3"
78
- steps :
79
- - s3/copy :
80
- from : artifact.tar
81
- to : ' s3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
82
- aws-access-key-id : env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
83
- aws-secret-access-key : env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
84
- aws-region : env_CONTEXT_ARTIFACT_S3_AWS_REGION
85
- arguments : ' --metadata "{\"x-amz-artifact-id\": \"${CIRCLE_SHA1}\" }"'
86
- upload_checksum :
87
- description : " upload artifact checksum to s3"
88
- steps :
89
- - s3/copy :
90
- from : artifact-info.txt
91
- to : ' s3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
92
- aws-access-key-id : env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
93
- aws-secret-access-key : env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
94
- aws-region : env_CONTEXT_ARTIFACT_S3_AWS_REGION
95
- docker_build :
86
+ name : Deploy docs to gh-pages branch
87
+ command : gh-pages -d dist --branch << parameters.target_branch >> --message '[skip ci]'
88
+ docker_build_push :
96
89
description : " Build Docker image"
97
90
steps :
98
91
- setup_remote_docker
99
92
- run :
100
93
name : Building docker image
101
94
command : |
102
95
docker build -t ${DOCKHUB_ORGANISATION}/binary-static-style:${CIRCLE_SHA1} -t ${DOCKHUB_ORGANISATION}/binary-static-style:latest .
103
- docker_push :
104
- description : " Push image to docker hub"
105
- steps :
106
96
- run :
107
97
name : Pushing Image to docker hub
108
98
command : |
@@ -130,29 +120,65 @@ commands:
130
120
echo $CA_CRT | base64 --decode > ca.crt
131
121
kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/style-binary-com style-binary-com=${DOCKHUB_ORGANISATION}/binary-static-style:${CIRCLE_SHA1}
132
122
fi
133
- done
123
+ done
124
+ notify_slack :
125
+ description : " Notify slack"
126
+ steps :
127
+ - slack/status :
128
+ include_project_field : false
129
+ failure_message : " Release failed for style.binary.com with version *$(cat dist/version)*"
130
+ success_message : " Release succeeded for style.binary.com with version *$(cat dist/version)*"
131
+ webhook : ${SLACK_WEBHOOK}
134
132
jobs :
135
- release :
133
+ build :
134
+ docker :
135
+ - image : circleci/node:9.9.0-stretch
136
+ steps :
137
+ - git_checkout_from_cache
138
+ - install_deps
139
+ - npm_install
140
+ - build
141
+ release_production :
142
+ docker :
143
+ - image : circleci/node:9.9.0-stretch
144
+ steps :
145
+ - git_checkout_from_cache
146
+ - install_deps
147
+ - npm_install
148
+ - build
149
+ - deploy :
150
+ target_branch : " production"
151
+ - notify_slack
152
+ release_aws_production :
136
153
docker :
137
154
- image : circleci/node:9.9.0-stretch
138
155
steps :
139
156
- git_checkout_from_cache
140
157
- install_deps
141
- - npm_install_from_cache
142
- - npm_build
143
- - compress
144
- - upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
145
- - upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint
146
- - docker_build
147
- - docker_push
158
+ - npm_install
159
+ - build
160
+ - docker_build_push
148
161
- k8s_deploy
149
162
150
163
workflows :
164
+ build :
165
+ jobs :
166
+ - build :
167
+ filters :
168
+ branches :
169
+ ignore : /^master$/
151
170
release :
152
171
jobs :
153
- - release :
172
+ - release_production :
173
+ filters :
174
+ branches :
175
+ ignore : /.*/
176
+ tags :
177
+ only : /^production.*/
178
+ - release_aws_production :
154
179
filters :
155
180
branches :
156
- only : /^master$/
157
- context : binary-frontend-artifact-upload # need to change the context name here
158
-
181
+ ignore : /.*/
182
+ tags :
183
+ only : /^production.*/
184
+ context : binary-frontend-artifact-upload
0 commit comments