-
Notifications
You must be signed in to change notification settings - Fork 139
/
deploy.sh
executable file
·63 lines (53 loc) · 2.16 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
ENV=$1
if [ "$2" = "no-cache" ]; then
NOCACHE=true
fi
echo $ENV
AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV}_AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV}_AWS_SECRET_ACCESS_KEY")
AWS_S3_BUCKET=$(eval "echo \$${ENV}_S3_BUCKET")
configure_aws_cli() {
aws --version
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
aws configure set default.output json
echo "Configured AWS CLI."
}
deploy_s3bucket() {
if [ "$NOCACHE" = "true" ]; then
S3_CACHE_OPTIONS="--cache-control private,no-store,no-cache,must-revalidate,max-age=0"
echo "*** Deploying with Cloudfront Cache disabled ***"
else
S3_CACHE_OPTIONS="--cache-control max-age=0,s-maxage=86400"
fi
S3_OPTIONS="--exclude '*.txt' --exclude '*.js' --exclude '*.css'"
echo aws s3 sync ./workspace/dist s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}
eval "aws s3 sync --dryrun ./workspace/dist s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}"
result=`eval "aws s3 sync ./workspace/dist s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}"`
if [ $? -eq 0 ]; then
echo "All html, font, image, map and media files are Deployed without gzip encoding!"
else
echo "Deployment Failed - $result"
exit 1
fi
S3_OPTIONS="--exclude '*' --include '*.txt' --include '*.js' --include '*.css' --content-encoding gzip"
echo aws s3 sync --dryrun ./workspace/dist s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}
eval "aws s3 sync --dryrun ./workspace/dist s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}"
result=`eval "aws s3 sync ./workspace/dist s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}"`
if [ $? -eq 0 ]; then
echo "All txt, css, and js files are Deployed! with gzip"
else
echo "Deployment Failed - $result"
exit 1
fi
}
echo -e "application/font-woff\t\t\t\twoff2" >> /etc/mime.types
echo -e "application/font-sfnt\t\t\t\tttf" >> /etc/mime.types
echo -e "application/json\t\t\t\tmap" >> /etc/mime.types
cat /etc/mime.types | grep -i woff
cat /etc/mime.types | grep -i ico
cat /etc/mime.types | grep -i map
cat /etc/mime.types | grep -i ttf
configure_aws_cli
deploy_s3bucket