-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(s3-cf): add script for deploying static sites
- Loading branch information
Showing
3 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
|
||
set -xe | ||
|
||
MISSING_ENV=0 | ||
|
||
if [[ -z "${SOURCE_DIR}" ]]; then | ||
echo "SOURCE_DIR env must be set" | ||
MISSING_ENV=1 | ||
fi | ||
|
||
if [[ -z "${AWS_S3_BUCKET}" ]]; then | ||
echo "AWS_S3_BUCKET env must be set" | ||
MISSING_ENV=1 | ||
fi | ||
|
||
if [[ -z "${AWS_CF_DISTRIBUTION_ID}" ]]; then | ||
echo "AWS_CF_DISTRIBUTION_ID env must be set" | ||
MISSING_ENV=1 | ||
fi | ||
|
||
if [[ "${MISSING_ENV}" == "1" ]]; then | ||
exit 1 | ||
fi | ||
|
||
aws s3 cp --recursive "${SOURCE_DIR}" "s3://${AWS_S3_BUCKET}/" | ||
AWS_CF_INVALIDATION_ID="$(aws cloudfront create-invalidation --distribution-id ${AWS_CF_DISTRIBUTION_ID} --paths '/*' | jq -r .Invalidation.Id)" | ||
echo "CloudFront Invalidation ID - ${AWS_CF_INVALIDATION_ID}" | ||
aws cloudfront wait invalidation-completed --distribution-id ${AWS_CF_DISTRIBUTION_ID} --id ${AWS_CF_INVALIDATION_ID} |