diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cba3f1e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +sudo: required +dist: trusty + +language: ruby +rvm: + - 2.3.0 + +cache: + bundler: true + directories: + - $TRAVIS_BUILD_DIR/node_modules + +before_install: + - nvm install 6 + +before_script: "_ci/setup.sh" +script: "_ci/build.sh" +after_success: "_ci/deploy.sh" + +# deploy: +# skip_cleanup: true +# provider: script +# script: "_ci/deploy.sh" +# on: +# all_branches: true + +notifications: + email: false diff --git a/README.md b/README.md index 1d345ed..f28a576 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > Landing page for BigchainDB -[ ![Codeship Status for ascribe/bigchain-website](https://codeship.com/projects/3204bb70-c384-0133-9cd7-5a80e4317151/status?branch=master)](https://codeship.com/projects/138094) +[![Build Status](https://travis-ci.com/ascribe/bigchain-website.svg?token=3psqw6c8KMDqfdGQ2x6d&branch=master)](https://travis-ci.com/ascribe/bigchain-website) [Live](https://www.bigchaindb.com) | [Beta](https://beta.bigchaindb.com) | [Styleguide](https://www.bigchaindb.com/styleguide/) @@ -32,11 +32,11 @@ gulp ## Continuous Delivery -The site gets built & deployed automatically via Codeship under the following conditions: +The site gets built & deployed automatically via Travis under the following conditions: - every push builds the site - every push to the master branch initiates a live deployment -- every push to a branch starting with `feature` initiates a beta deployment +- every pull request initiates a beta deployment ## Manual Deployment @@ -72,7 +72,7 @@ npm update && bundle update gulp build --production # deploy contents of /_dist to beta -gulp deploy:beta +gulp deploy --beta ``` ### Production build & live deployment @@ -85,5 +85,5 @@ npm update && bundle update gulp build --production # deploy contents of /_dist to live -gulp deploy:live +gulp deploy --live ``` diff --git a/_ci/build.sh b/_ci/build.sh index 578d49d..7b49a20 100755 --- a/_ci/build.sh +++ b/_ci/build.sh @@ -2,6 +2,16 @@ set -e; -gulp build --production +echo "$(tput setaf 136)" +echo "=============================================" +echo " Starting build " +echo "=============================================" +echo "$(tput sgr0)" # reset -exit; + gulp build --production + +echo "$(tput setaf 64)" # green +echo "---------------------------------------------" +echo " ✓ done building" +echo "---------------------------------------------" +echo "$(tput sgr0)" # reset diff --git a/_ci/deploy.sh b/_ci/deploy.sh index 62b8d7a..318e978 100755 --- a/_ci/deploy.sh +++ b/_ci/deploy.sh @@ -2,10 +2,35 @@ set -e; -if [ $CI_BRANCH == "master" ]; then - gulp deploy:live +## +## check for pull request against master +## +if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then + + gulp deploy --beta; + + +## +## check for master push which is no pull request +## +elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + + gulp deploy --live; + else - gulp deploy:beta + + echo "$(tput setaf 64)" # green + echo "---------------------------------------------" + echo " ✓ nothing to deploy " + echo "---------------------------------------------" + echo "$(tput sgr0)" # reset + fi; +echo "$(tput setaf 64)" # green +echo "---------------------------------------------" +echo " ✓ done deployment " +echo "---------------------------------------------" +echo "$(tput sgr0)" # reset + exit; diff --git a/_ci/setup.sh b/_ci/setup.sh index 0cf9922..538786e 100755 --- a/_ci/setup.sh +++ b/_ci/setup.sh @@ -2,8 +2,18 @@ set -e; +echo "$(tput setaf 136)" +echo " Installing dependencies " +echo "=============================================" +echo "$(tput sgr0)" # reset + npm install gulp -g npm install -bundle install -exit; +# Travis does that automatically after selecting ruby +#bundle install + +echo "$(tput setaf 64)" # green +echo "---------------------------------------------" +echo " ✓ done installing dependencies" +echo "$(tput sgr0)" # reset diff --git a/gulpfile.js b/gulpfile.js index c205d87..b029f55 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -319,17 +319,37 @@ gulp.task('build', function(done) { // Deployment // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -gulp.task('deploy:live', function() { +// +// gulp deploy --live +// gulp deploy --beta +// +gulp.task('deploy', function() { // create publisher, define config - var publisher = $.awspublish.create({ - params: { - 'Bucket': S3BUCKET - }, - 'accessKeyId': process.env.AWS_ACCESS_KEY, - 'secretAccessKey': process.env.AWS_SECRET_KEY, - 'region': S3REGION - }); + if ($.util.env.live === true) { + var publisher = $.awspublish.create({ + params: { "Bucket": S3BUCKET }, + "accessKeyId": process.env.AWS_ACCESS_KEY, + "secretAccessKey": process.env.AWS_SECRET_KEY, + "region": S3REGION + }); + + $.util.log($.util.colors.gray(" ------------------------------------------")); + $.util.log($.util.colors.green(' Deploying to Live... ')); + $.util.log($.util.colors.gray(" ------------------------------------------")); + } + if ($.util.env.beta === true) { + var publisher = $.awspublish.create({ + params: { "Bucket": S3BUCKET_BETA }, + "accessKeyId": process.env.AWS_BETA_ACCESS_KEY, + "secretAccessKey": process.env.AWS_BETA_SECRET_KEY, + "region": S3REGION_BETA + }); + + $.util.log($.util.colors.gray(" ------------------------------------------")); + $.util.log($.util.colors.green(' Deploying to Beta... ')); + $.util.log($.util.colors.gray(" ------------------------------------------")); + } return gulp.src(DIST + '**/*') .pipe($.awspublishRouter({ @@ -339,7 +359,7 @@ gulp.task('deploy:live', function() { }, routes: { // all static assets, cached & gzipped - '^assets/(?:.+)\\.(?:js|css|png|jpg|jpeg|gif|ico|svg|ttf|eot|woff|woff2)$': { + '^assets/(?:.+)\\.(?:js|css|png|jpg|jpeg|gif|ico|svg|ttf)$': { cacheTime: 2592000, // cache for 1 month gzip: true }, @@ -377,75 +397,8 @@ gulp.task('deploy:live', function() { "^.+$": "$&" } })) - .pipe(parallelize(publisher.publish(), 10)) + .pipe(parallelize(publisher.publish(), 100)) .pipe(publisher.sync()) // delete files in bucket that are not in local folder - .pipe(publisher.cache()) - .pipe($.awspublish.reporter({ - states: ['create', 'update', 'delete'] - })); -}); - -gulp.task('deploy:beta', function() { - - // create publisher, define config - var publisher = $.awspublish.create({ - params: { - 'Bucket': S3BUCKET_BETA - }, - 'accessKeyId': process.env.AWS_ACCESS_KEY, - 'secretAccessKey': process.env.AWS_SECRET_KEY, - 'region': S3REGION_BETA - }); - - return gulp.src(DIST + '**/*') - .pipe($.awspublishRouter({ - 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 - }, - - // font mime types - '\.eot$': { - key: '$&', - headers: { 'Content-Type': 'application/vnd.ms-fontobject' } - }, - '\.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 - "^.+$": "$&" - } - })) - .pipe(parallelize(publisher.publish(), 10)) - .pipe(publisher.sync()) // delete files in bucket that are not in local folder - .pipe(publisher.cache()) .pipe($.awspublish.reporter({ states: ['create', 'update', 'delete'] }));