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

Commit 3fcf072

Browse files
authored
Merge pull request #2437 from shudarshon-binary/dev
chaks/circleci pipeline rewrite for artifact upload to s3 bucket
2 parents a1e611d + a345126 commit 3fcf072

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

.circleci/config.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: 2.1
22
orbs:
33
k8s: circleci/kubernetes@0.7.0
4+
s3: circleci/aws-s3@1.0.13
45
commands:
56
git_checkout_from_cache:
67
description: "Git checkout and save cache"
@@ -46,14 +47,43 @@ commands:
4647
key: npm-v1-{{ checksum "package.json" }}
4748
paths:
4849
- "node_modules"
49-
5050
build:
5151
description: "Build"
5252
steps:
5353
- run:
5454
name: "yarn build"
5555
command: node_modules/gulp/bin/gulp.js build-min
56-
56+
compress:
57+
description: "Compress"
58+
steps:
59+
- run:
60+
name: "Compress"
61+
command: |
62+
pushd www/
63+
tar -cvf artifact.tar *
64+
mv artifact.tar ${OLDPWD}/
65+
- run:
66+
name: "Tag commit id as artifact identifer"
67+
command: echo "${CIRCLE_SHA1}" > artifact-info.txt
68+
upload_artifact:
69+
description: "upload artifact to s3"
70+
steps:
71+
- s3/copy:
72+
from: artifact.tar
73+
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
74+
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
75+
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
76+
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
77+
arguments: '--metadata "{\"x-amz-artifact-id\": \"${CIRCLE_SHA1}\" }"'
78+
upload_checksum:
79+
description: "upload artifact commit id to s3"
80+
steps:
81+
- s3/copy:
82+
from: artifact-info.txt
83+
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
84+
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
85+
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
86+
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
5787
docker:
5888
description: "Build and Push image to docker hub"
5989
parameters:
@@ -126,6 +156,9 @@ jobs:
126156
- git_checkout_from_cache
127157
- npm_install
128158
- build
159+
- compress
160+
- upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
161+
- upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint before actual deployment
129162
- docker:
130163
target: "production"
131164
- k8s_deploy:
@@ -134,8 +167,8 @@ jobs:
134167
workflows:
135168
test:
136169
jobs:
137-
- test
138-
170+
- test:
171+
context: binary-frontend-deploy
139172
release:
140173
jobs:
141174
- release_beta:
@@ -150,4 +183,5 @@ workflows:
150183
ignore: /.*/
151184
tags:
152185
only: /^production.*/
186+
context: binary-frontend-artifact-upload
153187

0 commit comments

Comments
 (0)