Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 9df1a7c

Browse files
author
sysadmin-frontend-binary
authored
Merge pull request #154 from Mahboobeh-binary/new-release-infra
update release proc
2 parents 02667d8 + 9cdb214 commit 9df1a7c

File tree

1 file changed

+65
-44
lines changed

1 file changed

+65
-44
lines changed

.circleci/config.yml

Lines changed: 65 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22
orbs:
33
k8s: circleci/[email protected]
4-
s3: circleci/[email protected]
4+
slack: circleci/[email protected]
55
commands:
66
git_checkout_from_cache:
77
description: "Git checkout and save cache"
@@ -47,48 +47,37 @@ commands:
4747
key: npm-v1-{{ checksum "package.json" }}
4848
paths:
4949
- "node_modules"
50-
5150
build:
5251
description: "Build"
5352
steps:
5453
- run:
5554
name: "yarn build"
5655
command: yarn build
57-
58-
compress:
59-
description: "Compress"
56+
deploy:
57+
description: "Deploy to static branches"
58+
parameters:
59+
target_branch:
60+
type: string
6061
steps:
62+
- checkout
63+
- attach_workspace:
64+
at: lib
65+
- run:
66+
name: Tag build
67+
command: echo "<< parameters.target_branch >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > lib/version
6168
- run:
62-
name: "Compress"
69+
name: Install and configure dependencies
6370
command: |
64-
pushd lib/
65-
tar -cvf artifact.tar *
66-
mv artifact.tar ${OLDPWD}/
71+
sudo npm install -g [email protected]
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"
6777
- run:
68-
name: "Tag commit id as artifact identifer"
69-
command: echo "${CIRCLE_SHA1}" > artifact-info.txt
70-
71-
upload_artifact:
72-
description: "upload build artifact to s3 bucket"
73-
steps:
74-
- s3/copy:
75-
from: artifact.tar
76-
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
77-
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
78-
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
79-
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
80-
arguments: '--metadata "{\"x-amz-artifact-id\": \"${CIRCLE_SHA1}\" }"'
81-
82-
upload_checksum:
83-
description: "upload artifact checksum to s3"
84-
steps:
85-
- s3/copy:
86-
from: artifact-info.txt
87-
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
88-
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
89-
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
90-
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
91-
docker:
78+
name: Deploy docs to gh-pages branch
79+
command: gh-pages -d lib --branch << parameters.target_branch >> --message '[skip ci]'
80+
docker_build_push:
9281
description: "Build and Push image to docker hub"
9382
steps:
9483
- setup_remote_docker
@@ -102,7 +91,6 @@ commands:
10291
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
10392
docker push ${DOCKHUB_ORGANISATION}/binary-static-liveapi:${CIRCLE_SHA1}
10493
docker push ${DOCKHUB_ORGANISATION}/binary-static-liveapi:latest
105-
10694
k8s_deploy:
10795
description: "Deploy to k8s cluster"
10896
steps:
@@ -125,26 +113,59 @@ commands:
125113
kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/liveapi-binary-com liveapi-binary-com=${DOCKHUB_ORGANISATION}/binary-static-liveapi:${CIRCLE_SHA1}
126114
fi
127115
done
128-
116+
notify_slack:
117+
description: "Notify slack"
118+
steps:
119+
- slack/status:
120+
include_project_field: false
121+
failure_message: "Release failed for liveapi.binary.com with version *$(cat lib/version)*"
122+
success_message: "Release succeeded for liveapi.binary.com with version *$(cat lib/version)*"
123+
webhook: ${SLACK_WEBHOOK}
129124
jobs:
130-
release:
125+
build:
126+
docker:
127+
- image: circleci/node:8.10.0-stretch
128+
steps:
129+
- git_checkout_from_cache
130+
- npm_install
131+
- build
132+
release_production:
133+
docker:
134+
- image: circleci/node:8.10.0-stretch
135+
steps:
136+
- git_checkout_from_cache
137+
- npm_install
138+
- build
139+
- deploy:
140+
target_branch: "production"
141+
- notify_slack
142+
release_aws_production:
131143
docker:
132144
- image: circleci/node:9.9.0-stretch
133145
steps:
134146
- git_checkout_from_cache
135147
- npm_install
136148
- build
137-
- compress
138-
- upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
139-
- upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint
140-
- docker
141-
- k8s_deploy
149+
- docker_build_push
150+
- k8s_deploy
151+
- notify_slack
142152

143153
workflows:
154+
build:
155+
jobs:
156+
- build
144157
release:
145158
jobs:
146-
- release:
159+
- release_production:
160+
filters:
161+
branches:
162+
ignore: /.*/
163+
tags:
164+
only: /^production.*/
165+
- release_aws_production:
147166
filters:
148167
branches:
149-
only: /^master$/
150-
context: binary-frontend-artifact-upload # using context to retrieve shared secret from circle ci
168+
ignore: /.*/
169+
tags:
170+
only: /^production.*/
171+
context: binary-frontend-artifact-upload

0 commit comments

Comments
 (0)