1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-29 07:16:17 +01:00

rewrite deploy script to use awscli

This commit is contained in:
Matthias Kretschmann 2018-02-02 13:09:32 +01:00
parent 27852f907d
commit 59c5e7b7be
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 44 additions and 24 deletions

View File

@ -1,14 +1,33 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# Required global environment variables:
#
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
# AWS_DEFAULT_REGION
#
set -e; set -e;
SOURCE="./_dist"
BUCKET_LIVE="www.bigchaindb.com"
BUCKET_BETA="beta.bigchaindb.com"
OPTIONS_DEFAULT="--delete --acl public-read"
OPTIONS_CACHING="--cache-control max-age=2592000,public"
## ##
## check for pull request against master ## check for pull request against master
## ##
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
#gulp deploy --beta; #gulp deploy --beta;
aws s3 sync ./_dist s3://beta.bigchaindb.com --delete --acl public-read --sse
echo "$(tput setaf 64)---------------------------------------------"
echo " Deploying to Beta "
echo "---------------------------------------------$(tput sgr0)"
aws s3 sync $SOURCE s3://$BUCKET_BETA --exclude "assets/*" $OPTIONS_DEFAULT
aws s3 sync $SOURCE s3://$BUCKET_BETA --exclude "*" --include "assets/*" $OPTIONS_DEFAULT $OPTIONS_CACHING
## ##
@ -17,22 +36,26 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; th
elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
#gulp deploy --live; #gulp deploy --live;
aws s3 sync ./_dist s3://www.bigchaindb.com --delete --acl public-read --sse
echo "$(tput setaf 64)---------------------------------------------"
echo " Deploying to Live "
echo "---------------------------------------------$(tput sgr0)"
aws s3 sync $SOURCE s3://$BUCKET_LIVE --exclude "assets/*" $OPTIONS_DEFAULT
aws s3 sync $SOURCE s3://$BUCKET_LIVE --exclude "*" --include "assets/*" $OPTIONS_DEFAULT $OPTIONS_CACHING
gulp seo --live
else else
echo "$(tput setaf 64)" # green echo "$(tput setaf 64)---------------------------------------------"
echo "---------------------------------------------"
echo " ✓ nothing to deploy " echo " ✓ nothing to deploy "
echo "---------------------------------------------" echo "---------------------------------------------$(tput sgr0)"
echo "$(tput sgr0)" # reset
fi; fi;
echo "$(tput setaf 64)" # green echo "$(tput setaf 64)---------------------------------------------"
echo "---------------------------------------------"
echo " ✓ done deployment " echo " ✓ done deployment "
echo "---------------------------------------------" echo "---------------------------------------------$(tput sgr0)"
echo "$(tput sgr0)" # reset
exit; exit;

View File

@ -57,15 +57,12 @@ const PORT = 1337
// paths // paths
const SRC = site.source, const SRC = site.source,
DIST = '_dist' DIST = site.destination
// deployment // deployment
const S3BUCKET = 'www.bigchaindb.com', const S3BUCKET = 'www.bigchaindb.com',
S3REGION = 'eu-central-1',
S3BUCKET_BETA = 'beta.bigchaindb.com', S3BUCKET_BETA = 'beta.bigchaindb.com',
S3REGION_BETA = 'eu-central-1', S3BUCKET_GAMMA = 'gamma.bigchaindb.com'
S3BUCKET_GAMMA = 'gamma.bigchaindb.com',
S3REGION_GAMMA = 'eu-central-1'
// SVG sprite // SVG sprite
const SPRITECONFIG = { const SPRITECONFIG = {
@ -370,23 +367,23 @@ export const s3 = () => {
if ($.util.env.live === true) { if ($.util.env.live === true) {
var publisher = $.awspublish.create({ var publisher = $.awspublish.create({
params: { 'Bucket': S3BUCKET }, params: { 'Bucket': S3BUCKET },
'accessKeyId': process.env.AWS_ACCESS_KEY, 'accessKeyId': process.env.AWS_ACCESS_KEY_ID,
'secretAccessKey': process.env.AWS_SECRET_KEY, 'secretAccessKey': process.env.AWS_SECRET_ACCESS_KEY,
'region': S3REGION 'region': process.env.AWS_DEFAULT_REGION
}) })
} else if ($.util.env.beta === true) { } else if ($.util.env.beta === true) {
var publisher = $.awspublish.create({ var publisher = $.awspublish.create({
params: { 'Bucket': S3BUCKET_BETA }, params: { 'Bucket': S3BUCKET_BETA },
'accessKeyId': process.env.AWS_BETA_ACCESS_KEY, 'accessKeyId': process.env.AWS_ACCESS_KEY_ID,
'secretAccessKey': process.env.AWS_BETA_SECRET_KEY, 'secretAccessKey': process.env.AWS_SECRET_ACCESS_KEY,
'region': S3REGION_BETA 'region': process.env.AWS_DEFAULT_REGION
}) })
} else if ($.util.env.gamma === true) { } else if ($.util.env.gamma === true) {
var publisher = $.awspublish.create({ var publisher = $.awspublish.create({
params: { 'Bucket': S3BUCKET_GAMMA }, params: { 'Bucket': S3BUCKET_GAMMA },
'accessKeyId': process.env.AWS_GAMMA_ACCESS_KEY, 'accessKeyId': process.env.AWS_ACCESS_KEY_ID,
'secretAccessKey': process.env.AWS_GAMMA_SECRET_KEY, 'secretAccessKey': process.env.AWS_SECRET_ACCESS_KEY,
'region': S3REGION_GAMMA 'region': process.env.AWS_DEFAULT_REGION
}) })
} }