From 624cd25702ba0f6a597872e8048d6586d1fc059a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 20 Mar 2017 16:16:03 +0100 Subject: [PATCH] prevent search engine indexing of beta & gamma - next strategy, cause https://github.com/ascribe/bigchain-website/commit/8103c6884e9d0855337f4dd7cb19b15208b59dfe didn't work --- README.md | 13 +++++++++---- _ci/build.sh | 20 ++++++++++++++++++++ gulpfile.js | 28 ++++++++++++++++------------ 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f9ffcbd..e597eea 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![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](http://beta.bigchaindb.com) | [Gamma](http://gamma.bigchaindb.com) | [Styleguide](https://www.bigchaindb.com/styleguide/) +[Live](https://www.bigchaindb.com) | [Styleguide](https://www.bigchaindb.com/styleguide/) | [Beta](http://beta.bigchaindb.com) | [Gamma](http://gamma.bigchaindb.com) ## Development @@ -69,14 +69,16 @@ AWS_PROFILE=bigchain gulp deploy --live In case that you get authentication errors or need an alternative way to authenticate with AWS, check out the [AWS documentation](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html). -### Production build & beta deployment +### Staging build & beta deployment + +The staging build is essentially a full production build but it prevents search engine indexing & Google Analytics tracking. ```bash # make sure your local npm packages & gems are up to date npm update && bundle update -# make production build in /_dist -gulp build --production +# make staging build in /_dist +gulp build --staging # deploy contents of /_dist to beta gulp deploy --beta @@ -85,6 +87,9 @@ gulp deploy --beta There's also a second beta deployment target called gamma under http://gamma.bigchaindb.com: ```bash +# build preventing search engine indexing & Google Analytics tracking +gulp build --staging + # deploy contents of /_dist to gamma gulp deploy --gamma ``` diff --git a/_ci/build.sh b/_ci/build.sh index 7b49a20..ba86a7e 100755 --- a/_ci/build.sh +++ b/_ci/build.sh @@ -8,8 +8,28 @@ echo " Starting build " echo "=============================================" echo "$(tput sgr0)" # reset +## +## check for pull request against master +## +if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then + + gulp build --staging + + +## +## check for master push which is no pull request +## +elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + gulp build --production +else + + gulp build --production + +fi; + + echo "$(tput setaf 64)" # green echo "---------------------------------------------" echo " ✓ done building" diff --git a/gulpfile.js b/gulpfile.js index 66b7842..bea4b07 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,7 +25,8 @@ var onError = function(error) { // 'development' is just default, production overrides are triggered // by adding the production flag to the gulp command e.g. `gulp build --production` -var isProduction = ($.util.env.production === true ? true : false); +var isProduction = ($.util.env.production === true ? true : false), + isStaging = ($.util.env.staging === true ? true : false); // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,6 +117,9 @@ gulp.task('jekyll', function(cb) { if (isProduction) { process.env.JEKYLL_ENV = 'production'; var jekyll_options = 'jekyll build'; + } else if (isStaging) { + process.env.JEKYLL_ENV = 'staging'; + var jekyll_options = 'jekyll build'; } else { process.env.JEKYLL_ENV = 'development'; var jekyll_options = 'jekyll build --incremental --drafts --future'; @@ -134,7 +138,7 @@ gulp.task('jekyll', function(cb) { // gulp.task('html', function() { return gulp.src(DIST + '/**/*.html') - .pipe($.if(isProduction, $.htmlmin({ + .pipe($.if(isProduction || isStaging, $.htmlmin({ collapseWhitespace: true, conservativeCollapse: true, removeComments: true, @@ -157,9 +161,9 @@ gulp.task('css', function() { .pipe($.sourcemaps.init()) .pipe($.sass().on('error', $.sass.logError)) .pipe($.autoprefixer({ browsers: COMPATIBILITY })) - .pipe($.if(isProduction, $.cssmin())) + .pipe($.if(isProduction || isStaging, $.cssmin())) .pipe($.if(!isProduction, $.sourcemaps.write())) - .pipe($.if(isProduction, $.header(BANNER, { pkg: pkg }))) + .pipe($.if(isProduction || isStaging, $.header(BANNER, { pkg: pkg }))) .pipe($.rename({ suffix: '.min' })) .pipe(gulp.dest(DIST + 'assets/css/')) .pipe(browser.stream()); @@ -176,9 +180,9 @@ gulp.task('js', function() { ]) .pipe($.sourcemaps.init()) .pipe($.include()) - .pipe($.if(isProduction, $.uglify())).on('error', onError) - .pipe($.if(!isProduction, $.sourcemaps.write())) - .pipe($.if(isProduction, $.header(BANNER, { pkg: pkg }))) + .pipe($.if(isProduction || isStaging, $.uglify())).on('error', onError) + .pipe($.if(!isProduction || !isStaging, $.sourcemaps.write())) + .pipe($.if(isProduction || isStaging, $.header(BANNER, { pkg: pkg }))) .pipe($.rename({suffix: '.min'})) .pipe(gulp.dest(DIST + 'assets/js/')); }); @@ -189,7 +193,7 @@ gulp.task('js', function() { // gulp.task('svg', function() { return gulp.src(SRC + '_assets/images/**/*.svg') - .pipe($.if(isProduction, $.imagemin({ + .pipe($.if(isProduction || isStaging, $.imagemin({ svgoPlugins: [{ removeRasterImages: true }] @@ -204,7 +208,7 @@ gulp.task('svg', function() { // gulp.task('images', function() { return gulp.src(SRC + '_assets/images/**/*') - .pipe($.if(isProduction, $.imagemin({ + .pipe($.if(isProduction || isStaging, $.imagemin({ optimizationLevel: 3, // png progressive: true, // jpg interlaced: true, // gif @@ -239,7 +243,7 @@ gulp.task('videos', function() { // gulp.task('rev', function() { // globbing is slow so do everything conditionally for faster dev build - if (isProduction) { + if (isProduction || isStaging) { return gulp.src(DIST + '/assets/**/*.{css,js,png,jpg,jpeg,svg,eot,ttf,woff,woff2}') .pipe($.rev()) .pipe(gulp.dest(DIST + '/assets/')) @@ -256,7 +260,7 @@ gulp.task('rev', function() { // gulp.task('rev:replace', function() { // globbing is slow so do everything conditionally for faster dev build - if (isProduction) { + if (isProduction || isStaging) { var manifest = gulp.src(DIST + '/assets/rev-manifest.json'); return gulp.src(DIST + '/**/*.{html,xml,txt,json,css,js}') @@ -326,7 +330,7 @@ gulp.task('default', ['build', 'server'], function() { gulp.task('build', function(done) { $.util.log($.util.colors.gray(" ------------------------------------------")); - $.util.log($.util.colors.green(' Building ' + ($.util.env.production ? 'production' : 'dev') + ' version...')); + $.util.log($.util.colors.green(' Building ' + ($.util.env.production ? 'production' : $.util.env.staging ? 'staging' : 'dev') + ' version...')); $.util.log($.util.colors.gray(" ------------------------------------------")); runSequence(