Skip to content

Commit

Permalink
add deploy folder
Browse files Browse the repository at this point in the history
  • Loading branch information
yifan9916 committed Oct 19, 2018
1 parent 1bfc7f9 commit 3d95d36
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deploy/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npm i
npm run build
32 changes: 32 additions & 0 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -ev

COMMIT_HASH=$(git rev-parse HEAD)
ASSET_PATH="/assets/external/${SERVICE}/${BRANCH}/${COMMIT_HASH}"

fail() {
echo "FAIL: $*"
exit 1
}

prepare_assets() {
sed -i -e "s=@@ASSET_PATH=${ASSET_PATH}=" dist/index.html
sed -i -e "s=showcar-icons.min.js.map=${ASSET_PATH}/showcar-icons.min.js.map=" dist/showcar-icons.min.js
}

upload_to_s3() {
echo "Uploading assets to S3"

aws --region "eu-west-1" s3 cp dist "s3://as24-assets-eu-west-1/${SERVICE}/${BRANCH}/${COMMIT_HASH}/" --recursive --exclude "*.html" --cache-control "max-age=2592000" --acl public-read

aws --region "eu-west-1" s3 cp dist "s3://as24-assets-eu-west-1/${SERVICE}/${BRANCH}/${COMMIT_HASH}/" --recursive --exclude "*" --include "*.html" --cache-control "max-age=300" --acl public-read

aws --region "eu-west-1" s3 cp dist "s3://as24-assets-eu-west-1/${SERVICE}/${BRANCH}/latest/" --recursive --exclude "*.html" --cache-control "max-age=2592000" --acl public-read

aws --region "eu-west-1" s3 cp dist "s3://as24-assets-eu-west-1/${SERVICE}/${BRANCH}/latest/" --recursive --exclude "*" --include "*.html" --cache-control "max-age=300" --acl public-read

aws --region "eu-west-1" s3 cp dist "s3://as24-assets-eu-west-1/${SERVICE}/" --recursive --exclude "*" --include "*-fragment.html" --cache-control "max-age=300" --acl public-read
}

prepare_assets
upload_to_s3

0 comments on commit 3d95d36

Please sign in to comment.