1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-27 04:10:03 +01:00
blog/scripts/deploy.sh

67 lines
1.7 KiB
Bash
Raw Normal View History

2018-07-11 17:56:13 +02:00
#!/usr/bin/env bash
#
# required environment variables:
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
# AWS_DEFAULT_REGION
AWS_S3_BUCKET="kremalicious.com"
AWS_S3_BUCKET_BETA="beta.kremalicious.com"
SITEMAP_URL="https%3A%2F%2Fkremalicious.com%2Fsitemap.xml"
2018-07-11 17:56:13 +02:00
#
set -e;
function s3sync {
2018-12-01 20:42:42 +01:00
aws s3 sync ./public s3://"$1" \
--cache-control public,max-age=31536000,immutable \
--delete \
2018-12-07 14:12:01 +01:00
--acl public-read
2018-07-11 17:56:13 +02:00
2018-12-01 20:42:42 +01:00
aws s3 sync ./public s3://"$1" \
--exclude "*" \
--include "*.html" \
--include "sw.js" \
2018-12-07 14:12:01 +01:00
--include "chunk-map.json" \
--include "sitemap.xml" \
--include ".iconstats.json" \
--include "humans.txt" \
--include "robots.txt" \
2018-12-01 20:42:42 +01:00
--cache-control public,max-age=0,must-revalidate \
--delete \
2018-12-07 14:12:01 +01:00
--acl public-read
2018-07-11 17:56:13 +02:00
}
##
## check for pull request against master
##
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
s3sync $AWS_S3_BUCKET_BETA
##
## check for master push which is no pull request
##
elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] || [ "$TRAVIS" != true ]; then
s3sync $AWS_S3_BUCKET
# ping search engines
# returns: HTTP_STATUSCODE URL
curl -sL -w "%{http_code} %{url_effective}\\n" \
"http://www.google.com/webmasters/tools/ping?sitemap=$SITEMAP_URL" -o /dev/null \
"http://www.bing.com/webmaster/ping.aspx?siteMap=$SITEMAP_URL" -o /dev/null
2018-07-11 17:56:13 +02:00
echo "---------------------------------------------"
echo " ✓ done deployment "
echo "---------------------------------------------"
exit;
else
echo "---------------------------------------------"
echo " nothing to deploy "
echo "---------------------------------------------"
fi