mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-22 01:36:55 +01:00
call aws cli from within gulp task
This commit is contained in:
parent
59c5e7b7be
commit
bc851f4a6e
@ -9,42 +9,19 @@
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## check for master push which is no pull request
|
## check for master push which is no pull request
|
||||||
##
|
##
|
||||||
elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||||
|
|
||||||
#gulp deploy --live;
|
gulp deploy --live;
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import request from 'request'
|
|||||||
import uglifyjs from 'uglify-es'
|
import uglifyjs from 'uglify-es'
|
||||||
import composer from 'gulp-uglify/composer'
|
import composer from 'gulp-uglify/composer'
|
||||||
const minify = composer(uglifyjs, console)
|
const minify = composer(uglifyjs, console)
|
||||||
|
const cp = require('child_process')
|
||||||
|
|
||||||
// get all the configs: `pkg` and `site`
|
// get all the configs: `pkg` and `site`
|
||||||
import pkg from './package.json'
|
import pkg from './package.json'
|
||||||
@ -60,9 +61,11 @@ const SRC = site.source,
|
|||||||
DIST = site.destination
|
DIST = site.destination
|
||||||
|
|
||||||
// deployment
|
// deployment
|
||||||
const S3BUCKET = 'www.bigchaindb.com',
|
const S3_BUCKET_LIVE = 'www.bigchaindb.com',
|
||||||
S3BUCKET_BETA = 'beta.bigchaindb.com',
|
S3_BUCKET_BETA = 'beta.bigchaindb.com',
|
||||||
S3BUCKET_GAMMA = 'gamma.bigchaindb.com'
|
S3_BUCKET_GAMMA = 'gamma.bigchaindb.com',
|
||||||
|
S3_OPTIONS_DEFAULT = '--delete --acl public-read',
|
||||||
|
S3_OPTIONS_CACHING = '--cache-control max-age=2592000,public'
|
||||||
|
|
||||||
// SVG sprite
|
// SVG sprite
|
||||||
const SPRITECONFIG = {
|
const SPRITECONFIG = {
|
||||||
@ -120,8 +123,7 @@ export const jekyll = (done) => {
|
|||||||
var jekyll_options = 'jekyll build --incremental --drafts --future'
|
var jekyll_options = 'jekyll build --incremental --drafts --future'
|
||||||
}
|
}
|
||||||
|
|
||||||
let spawn = require('child_process').spawn,
|
const jekyll = cp.execFile('bundle', ['exec', jekyll_options], { stdio: 'inherit' })
|
||||||
jekyll = spawn('bundle', ['exec', jekyll_options], { stdio: 'inherit' })
|
|
||||||
|
|
||||||
jekyll.on('error', (error) => onError() ).on('close', done)
|
jekyll.on('error', (error) => onError() ).on('close', done)
|
||||||
}
|
}
|
||||||
@ -362,92 +364,19 @@ export default dev
|
|||||||
// gulp deploy --beta
|
// gulp deploy --beta
|
||||||
// gulp deploy --gamma
|
// gulp deploy --gamma
|
||||||
//
|
//
|
||||||
export const s3 = () => {
|
export const s3 = (cb) => {
|
||||||
// create publisher, define config
|
let S3_BUCKET_TARGET
|
||||||
|
|
||||||
if ($.util.env.live === true) {
|
if ($.util.env.live === true) {
|
||||||
var publisher = $.awspublish.create({
|
S3_BUCKET_TARGET = S3_BUCKET_LIVE
|
||||||
params: { 'Bucket': S3BUCKET },
|
|
||||||
'accessKeyId': process.env.AWS_ACCESS_KEY_ID,
|
|
||||||
'secretAccessKey': process.env.AWS_SECRET_ACCESS_KEY,
|
|
||||||
'region': process.env.AWS_DEFAULT_REGION
|
|
||||||
})
|
|
||||||
} else if ($.util.env.beta === true) {
|
} else if ($.util.env.beta === true) {
|
||||||
var publisher = $.awspublish.create({
|
S3_BUCKET_TARGET = S3_BUCKET_BETA
|
||||||
params: { 'Bucket': S3BUCKET_BETA },
|
|
||||||
'accessKeyId': process.env.AWS_ACCESS_KEY_ID,
|
|
||||||
'secretAccessKey': process.env.AWS_SECRET_ACCESS_KEY,
|
|
||||||
'region': process.env.AWS_DEFAULT_REGION
|
|
||||||
})
|
|
||||||
} else if ($.util.env.gamma === true) {
|
} else if ($.util.env.gamma === true) {
|
||||||
var publisher = $.awspublish.create({
|
S3_BUCKET_TARGET = S3_BUCKET_GAMMA
|
||||||
params: { 'Bucket': S3BUCKET_GAMMA },
|
|
||||||
'accessKeyId': process.env.AWS_ACCESS_KEY_ID,
|
|
||||||
'secretAccessKey': process.env.AWS_SECRET_ACCESS_KEY,
|
|
||||||
'region': process.env.AWS_DEFAULT_REGION
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return src(DIST + '/**/*')
|
cp.exec(`aws s3 sync ${DIST} s3://${S3_BUCKET_TARGET} --exclude "assets/*" ${S3_OPTIONS_DEFAULT}`, (err) => cb(err))
|
||||||
.pipe($.awspublishRouter({
|
cp.exec(`aws s3 sync ${DIST} s3://${S3_BUCKET_TARGET} --exclude "*" --include "assets/*" ${S3_OPTIONS_DEFAULT} ${S3_OPTIONS_CACHING}`, (err) => cb(err))
|
||||||
cache: {
|
|
||||||
// cache for 5 minutes by default
|
|
||||||
cacheTime: 300
|
|
||||||
},
|
|
||||||
routes: {
|
|
||||||
// all static assets, cached & gzipped
|
|
||||||
'^assets/(?:.+)\\.(?:js|css|png|jpg|jpeg|gif|ico|svg|ttf|eot|woff|woff2)$': {
|
|
||||||
cacheTime: 2592000, // cache for 1 month
|
|
||||||
gzip: true
|
|
||||||
},
|
|
||||||
|
|
||||||
// every other asset, cached
|
|
||||||
'^assets/.+$': {
|
|
||||||
cacheTime: 2592000 // cache for 1 month
|
|
||||||
},
|
|
||||||
|
|
||||||
// all html files, not cached & gzipped
|
|
||||||
'^.+\\.html': {
|
|
||||||
cacheTime: 0,
|
|
||||||
gzip: true
|
|
||||||
},
|
|
||||||
|
|
||||||
// all pdf files, not cached
|
|
||||||
'^.+\\.pdf': {
|
|
||||||
cacheTime: 0
|
|
||||||
},
|
|
||||||
|
|
||||||
// all zip files, not cached
|
|
||||||
'^.+\\.zip': {
|
|
||||||
cacheTime: 0
|
|
||||||
},
|
|
||||||
|
|
||||||
// font mime types
|
|
||||||
'.ttf$': {
|
|
||||||
key: '$&',
|
|
||||||
headers: { 'Content-Type': 'application/x-font-ttf' }
|
|
||||||
},
|
|
||||||
'.woff$': {
|
|
||||||
key: '$&',
|
|
||||||
headers: { 'Content-Type': 'application/x-font-woff' }
|
|
||||||
},
|
|
||||||
'.woff2$': {
|
|
||||||
key: '$&',
|
|
||||||
headers: { 'Content-Type': 'application/x-font-woff2' }
|
|
||||||
},
|
|
||||||
|
|
||||||
// pass-through for anything that wasn't matched by routes above, to be uploaded with default options
|
|
||||||
'^.+$': '$&'
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
// Make sure everything goes to the root '/'
|
|
||||||
.pipe($.rename(path => {
|
|
||||||
path.dirname = '/' + path.dirname
|
|
||||||
}))
|
|
||||||
.pipe(parallelize(publisher.publish(), 100))
|
|
||||||
.pipe(publisher.sync()) // delete files in bucket that are not in local folder
|
|
||||||
.pipe($.awspublish.reporter({
|
|
||||||
states: ['create', 'update', 'delete']
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user