|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +ENV=$1 |
| 4 | +echo $ENV |
| 5 | +AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV}_AWS_ACCESS_KEY_ID") |
| 6 | +AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV}_AWS_SECRET_ACCESS_KEY") |
| 7 | +AWS_S3_BUCKET=$(eval "echo \$${ENV}_S3_BUCKET") |
| 8 | + |
| 9 | +configure_aws_cli() { |
| 10 | + aws --version |
| 11 | + aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID |
| 12 | + aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY |
| 13 | + aws configure set default.output json |
| 14 | + echo "Configured AWS CLI." |
| 15 | +} |
| 16 | + |
| 17 | +deploy_s3bucket() { |
| 18 | + cat dist/app.2e9868372e0e2992d5d2.css |
| 19 | + aws s3 sync --dryrun ${HOME}/${CIRCLE_PROJECT_REPONAME}/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*.txt" --exclude "*.js" --exclude "*.css" |
| 20 | + result=`aws s3 sync ${HOME}/${CIRCLE_PROJECT_REPONAME}/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*.txt" --exclude "*.js" --exclude "*.css"` |
| 21 | + if [ $? -eq 0 ]; then |
| 22 | + echo "All html, font, image, map, and media files are Deployed without gzip encoding!" |
| 23 | + else |
| 24 | + echo "Deployment Failed - $result" |
| 25 | + exit 1 |
| 26 | + fi |
| 27 | + aws s3 sync --dryrun ${HOME}/${CIRCLE_PROJECT_REPONAME}/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*" --include "*.txt" --include "*.js" --include "*.css" --content-encoding gzip |
| 28 | + result=`aws s3 sync ${HOME}/${CIRCLE_PROJECT_REPONAME}/dist s3://${AWS_S3_BUCKET} --cache-control max-age=0,s-maxage=86400 --exclude "*" --include "*.txt" --include "*.js" --include "*.css" --content-encoding gzip` |
| 29 | + if [ $? -eq 0 ]; then |
| 30 | + echo "All txt, css, and js files are Deployed! with gzip" |
| 31 | + else |
| 32 | + echo "Deployment Failed - $result" |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | + |
| 36 | +} |
| 37 | + |
| 38 | +echo -e "application/font-woff\t\t\t\twoff2" >> /etc/mime.types |
| 39 | +echo -e "application/font-sfnt\t\t\t\tttf" >> /etc/mime.types |
| 40 | +echo -e "application/json\t\t\t\tmap" >> /etc/mime.types |
| 41 | + |
| 42 | +cat /etc/mime.types | grep -i woff |
| 43 | +cat /etc/mime.types | grep -i ico |
| 44 | +cat /etc/mime.types | grep -i map |
| 45 | +cat /etc/mime.types | grep -i ttf |
| 46 | + |
| 47 | +configure_aws_cli |
| 48 | +deploy_s3bucket |
0 commit comments