Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 4edae28

Browse files
author
sysadmin-frontend-binary
authored
Merge pull request #1960 from gokula-krishna-dev/master
New release procedure
2 parents 82cabc0 + cde56d0 commit 4edae28

File tree

1 file changed

+52
-43
lines changed

1 file changed

+52
-43
lines changed

.circleci/config.yml

+52-43
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
version: 2.1
22
orbs:
33
k8s: circleci/[email protected]
4-
s3: circleci/[email protected]
54
commands:
65
git_checkout_from_cache:
76
description: "Git checkout and save cache"
@@ -12,19 +11,19 @@ commands:
1211
- source-v2-{{ .Branch }}-{{ .Revision }}
1312
- source-v2-{{ .Branch }}-
1413
- source-v2-
15-
- run:
16-
name: Fetch git tags
14+
- run:
15+
name: Fetch git tags
1716
command: |
1817
mkdir -p ~/.ssh
19-
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== ' >> ~/.ssh/known_hosts
18+
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' >> ~/.ssh/known_hosts
2019
# Fetch tags if git cache is present
2120
if [ -e /home/circleci/project/.git ]
2221
then
2322
git fetch origin --tags
2423
fi
2524
- checkout
2625
- run:
27-
name: Compress git objects
26+
name: Compress git objects
2827
command: git gc
2928
- save_cache:
3029
name: Git save cache
@@ -64,49 +63,46 @@ commands:
6463
key: _site-v1-{{ .Revision }}
6564
paths:
6665
- _site
67-
compress:
68-
description: "Compress"
66+
deploy_gh_pages:
67+
description: "Deploy to static branches"
68+
parameters:
69+
target_branch:
70+
type: string
6971
steps:
72+
- checkout
73+
- attach_workspace:
74+
at: _site
75+
- run:
76+
name: Tag build
77+
command: echo "<< parameters.target_branch >> $(date)" > _site/version
7078
- run:
71-
name: "Compress"
79+
name: Install and configure dependencies
7280
command: |
73-
pushd _site/
74-
tar -cvf artifact.tar *
75-
mv artifact.tar ${OLDPWD}/
81+
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
82+
sudo apt install nodejs
83+
mkdir "/home/circleci/.npm-packages"
84+
npm config set prefix "/home/circleci/.npm-packages"
85+
npm install -g [email protected]
86+
git config user.email "[email protected]"
87+
git config user.name "ci-build"
88+
- add_ssh_keys:
89+
fingerprints:
90+
- "01:67:4a:6d:26:9c:70:c4:1a:60:91:88:d9:dd:f0:83"
7691
- run:
77-
name: "Tag commit id as artifact identifer"
78-
command: echo "${CIRCLE_SHA1}" > artifact-info.txt
79-
upload_artifact:
80-
description: "upload artifact to s3"
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
92+
name: Deploy docs to gh-pages branch
93+
command: /home/circleci/.npm-packages/bin/gh-pages -d _site --branch << parameters.target_branch >> --message '[skip ci]'
9894
docker_build:
9995
description: "Build Docker image"
10096
steps:
10197
- setup_remote_docker
102-
- run:
98+
- run:
10399
name: Building docker image
104100
command: |
105101
docker build -t ${DOCKHUB_ORGANISATION}/binary-static-academy:${CIRCLE_SHA1} -t ${DOCKHUB_ORGANISATION}/binary-static-academy:latest .
106102
docker_push:
107103
description: "Push image to docker hub"
108104
steps:
109-
- run:
105+
- run:
110106
name: Pushing Image to docker hub
111107
command: |
112108
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
@@ -116,7 +112,7 @@ commands:
116112
description: "Deploy to k8s cluster"
117113
steps:
118114
- k8s/install-kubectl
119-
- run:
115+
- run:
120116
name: Deploying to k8s cluster for service binary-academy
121117
command: |
122118
for SERVER_ID in {1..5}
@@ -136,26 +132,39 @@ commands:
136132
done
137133
138134
jobs:
139-
release:
135+
release_production:
140136
docker:
141137
- image: circleci/ruby:2.6.5
142138
steps:
143139
- git_checkout_from_cache
144140
- bundle_install
145141
- 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 before actual deployment
149142
- docker_build
150143
- docker_push
151144
- k8s_deploy
152-
145+
- deploy_gh_pages:
146+
target_branch: "production"
147+
release_staging:
148+
docker:
149+
- image: circleci/ruby:2.6.5
150+
steps:
151+
- git_checkout_from_cache
152+
- bundle_install
153+
- release
154+
- deploy_gh_pages:
155+
target_branch: "staging"
156+
153157
workflows:
154158
release:
155159
jobs:
156-
- release:
160+
- release_staging:
161+
filters:
162+
branches:
163+
only: /^master$/
164+
- release_production:
157165
filters:
158166
branches:
159-
only: /^master/
167+
ignore: /.*/
168+
tags:
169+
only: /^production.*/
160170
context: binary-frontend-artifact-upload
161-

0 commit comments

Comments
 (0)