Last active
April 16, 2020 08:54
-
-
Save dankochetov/64605a21ed55e5db278ce23e2435433c to your computer and use it in GitHub Desktop.
CI script for frontend
This file contains hidden or 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
#!/usr/bin/env bash | |
# Enable commands logging | |
PS4="> " | |
set -x | |
set -e | |
if ! [[ -x "$(command -v pip3)" ]]; then | |
apt-get update && apt-get install -y python3-pip | |
fi | |
if ! [[ -x "$(command -v aws)" ]]; then | |
pip3 install -U awscli | |
fi | |
npm i | |
npm run build | |
# Replace with output folder name | |
DIST_FOLDER="out" | |
aws s3 sync ${DIST_FOLDER}/ "s3://${BUCKET_NAME}" \ | |
--acl=public-read \ | |
--delete | |
aws s3api copy-object \ | |
--copy-source "${BUCKET_NAME}"/index.html \ | |
--bucket "${BUCKET_NAME}" \ | |
--key index.html \ | |
--metadata-directive REPLACE \ | |
--cache-control "max-age=0" \ | |
--content-type "text/html" \ | |
--acl public-read | |
aws cloudfront create-invalidation \ | |
--distribution-id "${DISTRIBUTION_ID}" \ | |
--paths /\* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment