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

Commit 475c9bc

Browse files
author
sysadmin-frontend-binary
authored
Merge pull request #138 from Mahboobeh-binary/new-release-infra
New release infra
2 parents 37e2d9a + d224a87 commit 475c9bc

File tree

1 file changed

+73
-47
lines changed

1 file changed

+73
-47
lines changed

.circleci/config.yml

Lines changed: 73 additions & 47 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"
@@ -39,7 +39,7 @@ commands:
3939
command: |
4040
sudo apt-get update && sudo apt-get install -y ruby-full
4141
sudo gem install sass
42-
npm_install_from_cache:
42+
npm_install:
4343
description: "npm install and save cache"
4444
steps:
4545
- restore_cache:
@@ -55,54 +55,44 @@ commands:
5555
name: Save npm cache
5656
paths:
5757
- "node_modules"
58-
npm_build:
58+
build:
5959
description: "Grunt build the project"
6060
steps:
6161
- run:
6262
name: "Build binary-style"
6363
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
6669
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
6776
- run:
68-
name: "Compress"
77+
name: Install and configure dependencies
6978
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"
7385
- 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:
9689
description: "Build Docker image"
9790
steps:
9891
- setup_remote_docker
9992
- run:
10093
name: Building docker image
10194
command: |
10295
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:
10696
- run:
10797
name: Pushing Image to docker hub
10898
command: |
@@ -130,29 +120,65 @@ commands:
130120
echo $CA_CRT | base64 --decode > ca.crt
131121
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}
132122
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}
134132
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:
136153
docker:
137154
- image: circleci/node:9.9.0-stretch
138155
steps:
139156
- git_checkout_from_cache
140157
- 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
148161
- k8s_deploy
149162

150163
workflows:
164+
build:
165+
jobs:
166+
- build:
167+
filters:
168+
branches:
169+
ignore: /^master$/
151170
release:
152171
jobs:
153-
- release:
172+
- release_production:
173+
filters:
174+
branches:
175+
ignore: /.*/
176+
tags:
177+
only: /^production.*/
178+
- release_aws_production:
154179
filters:
155180
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

Comments
 (0)