From 37843229ab137f432853c5fb84e3f7cbc5b28844 Mon Sep 17 00:00:00 2001
From: Ray Schamp <ray@scratch.mit.edu>
Date: Tue, 27 Sep 2016 10:42:55 -0400
Subject: [PATCH] Build in same node environments as scratch-*

---
 .travis.yml  | 32 ++++++++++++++++++++------------
 package.json |  1 +
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index c4467c5aa..aaddb6a8b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,18 +1,26 @@
 language: node_js
 node_js:
 - '4.2'
+- 'stable'
 cache:
   directories:
   - node_modules
-env:
-  global:
-  - DEPLOY_MESSAGE='"Travis build ${TRAVIS_BUILD_NUMBER}"'
-before_deploy:
-    - git config --global user.email "no-reply@scratch.mit.edu"
-    - git config --global user.name "scratch-gui"
-deploy:
-  provider: script
-  script: make deploy
-  skip_cleanup: true
-  on:
-    branch: master
+after_script:
+- |
+  # RELEASE_BRANCHES and NPM_TOKEN defined in Travis settings panel
+  declare exitCode
+  $(npm bin)/travis-after-all
+  exitCode=$?
+  if [[
+    # Execute after all jobs finish successfully
+    $exitCode = 0 &&
+    # Only release on release branches
+    $RELEASE_BRANCHES =~ $TRAVIS_BRANCH &&
+    # Don't release on PR builds
+    $TRAVIS_PULL_REQUEST = "false"
+  ]]; then
+    # Publish to gh-pages as most recent committer
+    git config --global user.email $(git log --pretty=format:"%ce" -n1)
+    git config --global user.name $(git log --pretty=format:"%cn" -n1)
+    ./node_modules/.bin/gh-pages -x -r https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git -d playground -m "Build for $(git log --pretty=format:%H)"
+  fi
diff --git a/package.json b/package.json
index 866d0dec6..5b60df097 100644
--- a/package.json
+++ b/package.json
@@ -33,6 +33,7 @@
     "scratch-blocks": "*",
     "scratch-render": "*",
     "scratch-vm": "*",
+    "travis-after-all": "1.4.4",
     "webpack": "1.13.2",
     "webpack-dev-server": "1.15.2"
   }
-- 
GitLab