1
1
version : 2.1
2
2
orbs :
3
3
4
-
5
4
commands :
6
5
git_checkout_from_cache :
7
6
description : " Git checkout and save cache"
@@ -12,19 +11,19 @@ commands:
12
11
- source-v2-{{ .Branch }}-{{ .Revision }}
13
12
- source-v2-{{ .Branch }}-
14
13
- source-v2-
15
- - run :
16
- name : Fetch git tags
14
+ - run :
15
+ name : Fetch git tags
17
16
command : |
18
17
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
20
19
# Fetch tags if git cache is present
21
20
if [ -e /home/circleci/project/.git ]
22
21
then
23
22
git fetch origin --tags
24
23
fi
25
24
- checkout
26
25
- run :
27
- name : Compress git objects
26
+ name : Compress git objects
28
27
command : git gc
29
28
- save_cache :
30
29
name : Git save cache
@@ -64,49 +63,46 @@ commands:
64
63
key : _site-v1-{{ .Revision }}
65
64
paths :
66
65
- _site
67
- compress :
68
- description : " Compress"
66
+ deploy_gh_pages :
67
+ description : " Deploy to static branches"
68
+ parameters :
69
+ target_branch :
70
+ type : string
69
71
steps :
72
+ - checkout
73
+ - attach_workspace :
74
+ at : _site
75
+ - run :
76
+ name : Tag build
77
+ command : echo "<< parameters.target_branch >> $(date)" > _site/version
70
78
- run :
71
- name : " Compress "
79
+ name : Install and configure dependencies
72
80
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
+
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"
76
91
- 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]'
98
94
docker_build :
99
95
description : " Build Docker image"
100
96
steps :
101
97
- setup_remote_docker
102
- - run :
98
+ - run :
103
99
name : Building docker image
104
100
command : |
105
101
docker build -t ${DOCKHUB_ORGANISATION}/binary-static-academy:${CIRCLE_SHA1} -t ${DOCKHUB_ORGANISATION}/binary-static-academy:latest .
106
102
docker_push :
107
103
description : " Push image to docker hub"
108
104
steps :
109
- - run :
105
+ - run :
110
106
name : Pushing Image to docker hub
111
107
command : |
112
108
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
@@ -116,7 +112,7 @@ commands:
116
112
description : " Deploy to k8s cluster"
117
113
steps :
118
114
- k8s/install-kubectl
119
- - run :
115
+ - run :
120
116
name : Deploying to k8s cluster for service binary-academy
121
117
command : |
122
118
for SERVER_ID in {1..5}
@@ -136,26 +132,39 @@ commands:
136
132
done
137
133
138
134
jobs :
139
- release :
135
+ release_production :
140
136
docker :
141
137
- image : circleci/ruby:2.6.5
142
138
steps :
143
139
- git_checkout_from_cache
144
140
- bundle_install
145
141
- 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
149
142
- docker_build
150
143
- docker_push
151
144
- 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
+
153
157
workflows :
154
158
release :
155
159
jobs :
156
- - release :
160
+ - release_staging :
161
+ filters :
162
+ branches :
163
+ only : /^master$/
164
+ - release_production :
157
165
filters :
158
166
branches :
159
- only : /^master/
167
+ ignore : /.*/
168
+ tags :
169
+ only : /^production.*/
160
170
context : binary-frontend-artifact-upload
161
-
0 commit comments