Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit cce842a

Browse files
author
sysadmin-frontend-binary
authored
Merge pull request #163 from Mahboobeh-binary/new-release-proc
New release proc
2 parents 30b466c + f401ee9 commit cce842a

File tree

1 file changed

+67
-44
lines changed

1 file changed

+67
-44
lines changed

.circleci/config.yml

Lines changed: 67 additions & 44 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"
@@ -48,7 +48,7 @@ commands:
4848
key: bundle-v1-{{ checksum "Gemfile" }}
4949
paths:
5050
- "modules"
51-
release:
51+
build:
5252
description: "Build Jekyll site"
5353
steps:
5454
- restore_cache:
@@ -64,48 +64,40 @@ commands:
6464
key: _site-v1-{{ .Revision }}
6565
paths:
6666
- _site
67-
compress:
68-
description: "Compress"
67+
deploy:
68+
description: "Deploy to static branches"
69+
parameters:
70+
target_branch:
71+
type: string
6972
steps:
73+
- checkout
74+
- attach_workspace:
75+
at: _site
76+
- run:
77+
name: Tag build
78+
command: echo "<< parameters.target_branch >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > _site/version
7079
- run:
71-
name: "Compress"
80+
name: Install and configure dependencies
7281
command: |
73-
pushd _site/
74-
tar -cvf artifact.tar *
75-
mv artifact.tar ${OLDPWD}/
82+
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
83+
sudo apt install nodejs
84+
sudo npm install gh-pages@2.0.1
85+
git config user.email "ci-build@binary.com"
86+
git config user.name "ci-build"
87+
- add_ssh_keys:
88+
fingerprints:
89+
- "01:67:4a:6d:26:9c:70:c4:1a:60:91:88:d9:dd:f0:83"
7690
- run:
77-
name: "Tag commit id as artifact identifer"
78-
command: echo "${CIRCLE_SHA1}" > artifact-info.txt
79-
upload_artifact:
80-
description: "upload build artifact to s3 bucket"
81-
steps:
82-
- s3/copy:
83-
from: artifact.tar
84-
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
85-
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
86-
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
87-
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
88-
arguments: '--metadata "{\"x-amz-artifact-id\": \"${CIRCLE_SHA1}\" }"'
89-
upload_checksum:
90-
description: "upload artifact checksum to s3"
91-
steps:
92-
- s3/copy:
93-
from: artifact-info.txt
94-
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
95-
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
96-
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
97-
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
98-
docker_build:
91+
name: Deploy docs to gh-pages branch
92+
command: node ./node_modules/gh-pages/bin/gh-pages -d _site --branch << parameters.target_branch >> --message '[skip ci]'
93+
docker_build_push:
9994
description: "Build Docker image"
10095
steps:
10196
- setup_remote_docker
10297
- run:
10398
name: Building docker image
10499
command: |
105100
docker build -t ${DOCKHUB_ORGANISATION}/binary-static-developers:${CIRCLE_SHA1} -t ${DOCKHUB_ORGANISATION}/binary-static-developers:latest .
106-
docker_push:
107-
description: "Push image to docker hub"
108-
steps:
109101
- run:
110102
name: Pushing Image to docker hub
111103
command: |
@@ -134,27 +126,58 @@ commands:
134126
kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/developers-binary-com developers-binary-com=${DOCKHUB_ORGANISATION}/binary-static-developers:${CIRCLE_SHA1}
135127
fi
136128
done
137-
129+
notify_slack:
130+
description: "Notify slack"
131+
steps:
132+
- slack/status:
133+
include_project_field: false
134+
failure_message: "Release failed for developers.binary.com with version *$(cat _site/version)*"
135+
success_message: "Release succeeded for developers.binary.com with version *$(cat _site/version)*"
136+
webhook: ${SLACK_WEBHOOK}
138137
jobs:
139-
release:
138+
build:
140139
docker:
141140
- image: circleci/ruby:2.6.5
142141
steps:
143142
- git_checkout_from_cache
144143
- bundle_install
145-
- release
146-
- compress
147-
- upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
148-
- upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint
149-
- docker_build
150-
- docker_push
144+
- build
145+
release_production:
146+
docker:
147+
- image: circleci/ruby:2.6.5
148+
steps:
149+
- git_checkout_from_cache
150+
- bundle_install
151+
- build
152+
- deploy:
153+
target_branch: "production"
154+
- notify_slack
155+
release_aws_production:
156+
docker:
157+
- image: circleci/ruby:2.6.5
158+
steps:
159+
- git_checkout_from_cache
160+
- bundle_install
161+
- build
162+
- docker_build_push
151163
- k8s_deploy
152164

153165
workflows:
166+
build:
167+
jobs:
168+
- build
154169
release:
155170
jobs:
156-
- release:
171+
- release_production:
172+
filters:
173+
branches:
174+
ignore: /.*/
175+
tags:
176+
only: /^production.*/
177+
- release_aws_production:
157178
filters:
158179
branches:
159-
only: /^gh-pages$/
160-
context: binary-frontend-artifact-upload # using context to retrieve shared secret from circle ci
180+
ignore: /.*/
181+
tags:
182+
only: /^production.*/
183+
context: binary-frontend-artifact-upload

0 commit comments

Comments
 (0)