Use https://github.com/settings/tokens/new
npm install pwmckenna/node-travis-encrypt -g
travis-encrypt -r <username>/<repo name> GH_TOKEN=<OAUTH TOKEN>
language: node_js
node_js:
- 4.1
env:
global:
- GH_REF: github.com/<username>/<repo>.git
- GIT_NAME: Travis-CI
- GIT_EMAIL: travis@nodemeatspace.com
- secure: <encrypted oAuth token>
before_install:
- chmod +x deploy_ghpages.sh
before_script:
- npm install
script: bash ./deploy_ghpages.sh
branches:
only:
- master
#!/bin/bash
# This makes sure, that we don't deploy pull requests to gh-pages :-)
if [ $TRAVIS_PULL_REQUEST != false ];
then
echo "Not deploying test-run for a pull request"
exit 0
fi
(
echo "Pushing build to ${GH_REF} gh-pages branch."
git checkout -b gh-pages
# inside this git repo we'll pretend to be a new user
git config user.name "${GIT_NAME}"
git config user.email "${GIT_EMAIL}"
# The first and only commit to this new Git repo contains all the
# files present with the commit message "Deploy to GitHub Pages".
git add .
git commit -m "Deployed to Github Pages" > /dev/null
# Force push from the current repo's master branch to the remote
# repo's gh-pages branch. (All previous history on the gh-pages branch
# will be lost, since we are overwriting it.) We redirect any output to
# /dev/null to hide any sensitive credential data that might otherwise be exposed.
git push --force "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1
echo "New gh-pages branch has been pushed to ${GH_REF}."
)