Skip to content

Commit 8fee7bf

Browse files
authored
Add a production deployment job (#180)
* Initial deploy configuration * Make sure we always deploy to a subdirectory of the specified bucket * Update the aws-cli orb * Alphabetize the spice rack * Trust the pipeline to provide the build directory if we make it this far * Remove some extra whitespace
1 parent 596644b commit 8fee7bf

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

.circleci/config.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ parameters:
66
default: ""
77

88
orbs:
9-
aws-cli: circleci/aws-cli@5.3.5
9+
aws-cli: circleci/aws-cli@5.4.1
1010
vale: circleci/[email protected]
1111

1212
executors:
@@ -109,7 +109,6 @@ jobs:
109109
- notify_error:
110110
message: "Build job failed for branch ${CIRCLE_BRANCH}"
111111

112-
113112
validate:
114113
executor: ruby_executor
115114
steps:
@@ -130,7 +129,6 @@ jobs:
130129
- notify_error:
131130
message: "Validation job failed for branch ${CIRCLE_BRANCH}"
132131

133-
134132
deploy-preview:
135133
executor: node_executor
136134
steps:
@@ -185,19 +183,34 @@ jobs:
185183
- notify_error:
186184
message: "Deploy preview job failed for branch ${CIRCLE_BRANCH}"
187185

188-
189186
deploy-production:
190187
executor: node_executor
188+
parameters:
189+
bucket_dir:
190+
default: "dorian"
191+
description: The directory in the bucket to deploy to.
192+
type: string
193+
bucket_name:
194+
description: The name of the s3 bucket where static assets are stored.
195+
type: string
196+
build_dir:
197+
default: "build"
198+
description: The path to the docs build directory
199+
type: string
191200
steps:
192201
- attach_workspace:
193202
at: .
194203
- aws-setup
195204
- run:
196205
name: Deploy Production Site to S3
197206
command: |
207+
AWS_S3_BUCKET=<< parameters.bucket_name >>
208+
BUCKET_DIRECTORY=<< parameters.bucket_dir >>
209+
BUILD_DIRECTORY=<< parameters.build_dir >>
210+
198211
set -e
199212
echo "[INFO] Deploying production site..."
200-
aws s3 sync build s3://${DOCS_BUILD_BUCKET}/ --delete --endpoint-url ${S3_ENDPOINT}
213+
aws s3 cp "$BUILD_DIRECTORY" "s3://$AWS_S3_BUCKET/$BUCKET_DIRECTORY/" --recursive
201214
- notify_error:
202215
message: "Production deployment job failed for branch ${CIRCLE_BRANCH}"
203216

@@ -242,12 +255,10 @@ jobs:
242255
echo "[WARN] Tag '${TAG}' not found."
243256
fi
244257
245-
246258
workflows:
247-
248259
lint:
249260
unless:
250-
equal: [ main, << pipeline.git.branch >> ]
261+
equal: [main, << pipeline.git.branch >>]
251262
jobs:
252263
- vale/lint:
253264
reference_branch: main
@@ -272,6 +283,9 @@ workflows:
272283
branches:
273284
only: main
274285
context: circleci-docs-static
286+
bucket_dir: "dorian"
287+
bucket_name: "circleci-docs-platform-assets/docs"
288+
build_dir: "build"
275289
cleanup_preview:
276290
when: pipeline.parameters.cleanup_preview_branch != ""
277291
jobs:

0 commit comments

Comments
 (0)