2018-05-14 01:50:11 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# required environment variables:
|
|
|
|
# AWS_ACCESS_KEY_ID
|
|
|
|
# AWS_SECRET_ACCESS_KEY
|
|
|
|
# AWS_DEFAULT_REGION
|
2018-05-25 16:43:04 +02:00
|
|
|
AWS_S3_BUCKET="matthiaskretschmann.com"
|
|
|
|
AWS_S3_BUCKET_BETA="beta.matthiaskretschmann.com"
|
2018-05-14 01:50:11 +02:00
|
|
|
#
|
|
|
|
set -e;
|
|
|
|
|
2018-05-25 16:43:04 +02:00
|
|
|
function s3sync {
|
|
|
|
aws s3 sync ./public s3://"$1" --exclude "*.html" --exclude "*.js" --cache-control max-age=31536000,public --delete --acl public-read
|
|
|
|
|
|
|
|
aws s3 sync ./public s3://"$1" --exclude "*" --include "*.html" --include "*.js" --cache-control max-age=0,no-cache,no-store,must-revalidate --delete --acl public-read
|
|
|
|
}
|
|
|
|
|
2018-05-14 01:50:11 +02:00
|
|
|
##
|
|
|
|
## check for pull request against master
|
|
|
|
##
|
|
|
|
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
|
|
|
|
|
2018-05-25 16:43:04 +02:00
|
|
|
s3sync $AWS_S3_BUCKET_BETA
|
2018-05-14 01:50:11 +02:00
|
|
|
|
|
|
|
##
|
|
|
|
## check for master push which is no pull request
|
|
|
|
##
|
|
|
|
elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] || [ "$TRAVIS" != true ]; then
|
|
|
|
|
2018-05-25 16:43:04 +02:00
|
|
|
s3sync $AWS_S3_BUCKET
|
2018-05-14 01:50:11 +02:00
|
|
|
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
echo " ✓ done deployment "
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
echo " nothing to deploy "
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
|
|
|
|
fi
|