Skip to content

Commit 673ee11

Browse files
Merge pull request #2 from Mahboobeh-binary/new-release-proc
New release proc
2 parents 488a575 + 6b65326 commit 673ee11

File tree

1 file changed

+65
-100
lines changed

1 file changed

+65
-100
lines changed

.circleci/config.yml

Lines changed: 65 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22
orbs:
33
k8s: circleci/kubernetes@0.7.0
4-
s3: circleci/aws-s3@1.0.13
4+
slack: circleci/slack@3.4.2
55
commands:
66
git_checkout_from_cache:
77
description: "Git checkout and save cache"
@@ -29,7 +29,7 @@ commands:
2929
key: source-v1-{{ .Branch }}-{{ .Revision }}
3030
paths:
3131
- ".git"
32-
npm_install_from_cache:
32+
npm_install:
3333
description: "npm install and save cache"
3434
steps:
3535
- restore_cache:
@@ -43,13 +43,13 @@ commands:
4343
key: node-{{ checksum "package-lock.json" }}
4444
paths:
4545
- "node_modules"
46-
npm_test:
46+
test:
4747
description: "Run npm test"
4848
steps:
4949
- run:
5050
name: "Run test"
5151
command: npm test
52-
grunt_release:
52+
build:
5353
description: "Build for release target"
5454
parameters:
5555
target:
@@ -59,65 +59,38 @@ commands:
5959
- run:
6060
name: Building dist for << parameters.target >>
6161
command: node_modules/grunt/bin/grunt releaseci --<< parameters.target >>
62-
compress:
63-
description: "Compress"
62+
deploy:
63+
description: "Deploy to static branches"
64+
parameters:
65+
target_branch:
66+
type: string
6467
steps:
68+
- checkout
69+
- attach_workspace:
70+
at: dist
6571
- run:
66-
name: "Compress"
67-
command: |
68-
pushd dist/
69-
tar -cvf artifact.tar *
70-
mv artifact.tar ${OLDPWD}/
72+
name: Tag build
73+
command: echo "<< parameters.target_branch >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > dist/version
7174
- run:
72-
name: "Tag commit id as artifact identifer"
73-
command: echo "${CIRCLE_TAG}" > artifact-info.txt
74-
upload_artifact:
75-
description: "upload build artifact to s3 bucket"
76-
steps:
77-
- s3/copy:
78-
from: artifact.tar
79-
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
80-
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
81-
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
82-
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
83-
arguments: '--metadata "{\"x-amz-artifact-id\": \"${CIRCLE_TAG}\" }"'
84-
upload_checksum:
85-
description: "upload artifact checksum to s3"
86-
steps:
87-
- s3/copy:
88-
from: artifact-info.txt
89-
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
90-
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
91-
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
92-
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
93-
docker_build_staging:
94-
description: "Build Docker image"
95-
steps:
96-
- setup_remote_docker
97-
- run:
98-
name: Building docker image
75+
name: Install and configure dependencies
9976
command: |
100-
docker build -t ${DOCKHUB_ORGANISATION}/binary-static:${CIRCLE_TAG} -t ${DOCKHUB_ORGANISATION}/binary-static:staging-latest .
101-
docker_build_production:
77+
sudo npm install -g gh-pages@2.0.1
78+
git config user.email "ci-build@binary.com"
79+
git config user.name "ci-build"
80+
- add_ssh_keys:
81+
fingerprints:
82+
- "17:6f:1c:8f:d6:05:11:fc:2a:cb:97:81:d7:ca:6d:58"
83+
- run:
84+
name: Deploy docs to gh-pages branch
85+
command: gh-pages -d dist --branch << parameters.target_branch >>
86+
docker_build_push:
10287
description: "Build Docker image"
10388
steps:
10489
- setup_remote_docker
10590
- run:
10691
name: Building docker image
10792
command: |
10893
docker build -t ${DOCKHUB_ORGANISATION}/binary-static:${CIRCLE_TAG} -t ${DOCKHUB_ORGANISATION}/binary-static:production-latest .
109-
docker_push_staging:
110-
description: "Push image to docker hub"
111-
steps:
112-
- run:
113-
name: Pushing Image to docker hub
114-
command: |
115-
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
116-
docker push ${DOCKHUB_ORGANISATION}/binary-static:${CIRCLE_TAG}
117-
docker push ${DOCKHUB_ORGANISATION}/binary-static:staging-latest
118-
docker_push_production:
119-
description: "Push image to docker hub"
120-
steps:
12194
- run:
12295
name: Pushing Image to docker hub
12396
command: |
@@ -150,89 +123,81 @@ commands:
150123
kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/<< parameters.k8s_svc_name >> << parameters.k8s_svc_name >>=${DOCKHUB_ORGANISATION}/binary-static:${CIRCLE_TAG}
151124
fi
152125
done
126+
notify_slack:
127+
description: "Notify slack"
128+
steps:
129+
- slack/status:
130+
include_project_field: false
131+
failure_message: "Release failed for Binary.com with version *$(cat dist/compressed/version)*"
132+
success_message: "Release succeeded for Binary.com with version *$(cat dist/compressed/version)*"
133+
webhook: ${SLACK_WEBHOOK}
153134
jobs:
154135
test:
155136
docker:
156137
- image: circleci/node:9.8.0-stretch
157138
steps:
158139
- git_checkout_from_cache
159-
- npm_install_from_cache
160-
- npm_test
161-
162-
build_push_staging:
140+
- npm_install
141+
- test
142+
release_beta:
163143
docker:
164144
- image: circleci/node:9.8.0-stretch
165145
steps:
166146
- git_checkout_from_cache
167-
- npm_install_from_cache
168-
- grunt_release:
147+
- npm_install
148+
- test
149+
- build:
169150
target: 'staging'
170-
- grunt_release:
151+
- build:
171152
target: 'translations'
172-
- docker_build_staging
173-
- docker_push_staging
174-
175-
build_push_production:
153+
- deploy:
154+
target_branch: "staging"
155+
- notify_slack
156+
release_production:
176157
docker:
177158
- image: circleci/node:9.8.0-stretch
178159
steps:
179160
- git_checkout_from_cache
180-
- npm_install_from_cache
181-
- grunt_release:
161+
- npm_install
162+
- test
163+
- build:
182164
target: 'production'
183-
- compress
184-
- upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
185-
- upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint
186-
- docker_build_production
187-
- docker_push_production
188-
189-
deploy_staging:
190-
docker:
191-
- image: circleci/node:9.8.0-stretch
192-
steps:
193-
- k8s_deploy
194-
195-
deploy_production:
165+
- deploy:
166+
target_branch: "production"
167+
- notify_slack
168+
release_aws_production:
196169
docker:
197170
- image: circleci/node:9.8.0-stretch
198171
steps:
172+
- git_checkout_from_cache
173+
- npm_install
174+
- test
175+
- build:
176+
target: 'production'
177+
- docker_build_push
199178
- k8s_deploy:
200179
k8s_svc_name: "production-binary-com"
201180

202181
workflows:
203182
test:
204183
jobs:
205-
- test
206-
tagged_release_staging:
207-
jobs:
208-
- build_push_staging:
184+
- test:
209185
filters:
210186
branches:
211-
ignore: /.*/
212-
tags:
213-
only: /^staging.*/
214-
context: binary-frontend-artifact-upload
215-
- deploy_staging:
216-
requires:
217-
- build_push_staging
187+
ignore: /^master$/
188+
release:
189+
jobs:
190+
- release_beta:
218191
filters:
219192
branches:
220-
ignore: /.*/
221-
tags:
222-
only: /^staging.*/
223-
context: binary-frontend-artifact-upload
224-
tagged_release_production:
225-
jobs:
226-
- build_push_production:
193+
only: /^master$/
194+
- release_production:
227195
filters:
228196
branches:
229197
ignore: /.*/
230198
tags:
231199
only: /^production.*/
232-
context: binary-frontend-artifact-upload
233-
- deploy_production:
234-
requires:
235-
- build_push_production
200+
- release_aws_production:
236201
filters:
237202
branches:
238203
ignore: /.*/

0 commit comments

Comments
 (0)