2018-11-16 11:12:28 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# required environment variables:
|
|
|
|
# AWS_ACCESS_KEY_ID
|
|
|
|
# AWS_SECRET_ACCESS_KEY
|
|
|
|
# AWS_DEFAULT_REGION
|
|
|
|
AWS_S3_BUCKET="docs.oceanprotocol.com"
|
2018-11-16 17:39:13 +01:00
|
|
|
AWS_S3_BUCKET_BETA="betadocs.oceanprotocol.com"
|
2018-11-16 11:12:28 +01:00
|
|
|
SITEMAP_URL="https%3A%2F%2Fdocs.oceanprotocol.com%2Fsitemap.xml"
|
|
|
|
|
|
|
|
#
|
|
|
|
set -e;
|
|
|
|
|
|
|
|
function s3sync {
|
2018-11-26 11:46:03 +01:00
|
|
|
aws s3 sync ./public s3://"$1" \
|
|
|
|
--exclude "*" \
|
|
|
|
--include "*.js" \
|
|
|
|
--include "*.css" \
|
|
|
|
--include "static/*" \
|
|
|
|
--include "icons/*" \
|
|
|
|
--exclude "sw.js" \
|
|
|
|
--exclude "workbox*/*" \
|
|
|
|
--cache-control public,max-age=31536000,immutable \
|
|
|
|
--delete \
|
|
|
|
--acl public-read \
|
|
|
|
--quiet
|
2018-11-16 11:12:28 +01:00
|
|
|
|
2018-11-26 11:46:03 +01:00
|
|
|
aws s3 sync ./public s3://"$1" \
|
|
|
|
--exclude "*" \
|
|
|
|
--include "*.html" \
|
|
|
|
--include "sw.js" \
|
|
|
|
--cache-control public,max-age=0,must-revalidate \
|
|
|
|
--delete \
|
|
|
|
--acl public-read \
|
|
|
|
--quiet
|
2018-11-16 11:12:28 +01: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
|
2018-11-29 10:37:58 +01:00
|
|
|
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-11-16 11:12:28 +01:00
|
|
|
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
echo " ✓ done deployment "
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
echo " nothing to deploy "
|
|
|
|
echo "---------------------------------------------"
|
|
|
|
|
|
|
|
fi
|