Taken from https://medium.com/@nthgergo/publishing-gh-pages-with-travis-ci-53a8270e87db
Create an OAuth token and encrypt it
Use https://github.com/settings/tokens/new
1 2 3
| gem install travis travis encrypt -r user/repo GITHUB_TOKEN=[the token here]
|
Make it run the deploy script on deploy
1 2 3 4 5 6 7
| script: - bash ./scripts/deploy-to-gh-pages.sh env: global: - GITHUB_REPO: "user/repo" - secure: "nlnXJW/imf/w..."
|
Write deployer
Create the file scripts/deploy-to-gh-pages.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #!/bin/bash
set -o errexit
rm -rf public mkdir public
git config --global user.email "nobody@nobody.org" git config --global user.name "Travis CI"
make
cd public git init git add . git commit -m "Deploy to Github Pages" git push --force --quiet "https://${GITHUB_TOKEN}@$github.com/${GITHUB_REPO}.git" master:gh-pages > /dev/null 2>&1
|
From Ractive, this might be useful in certain cases:
1
| if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "master" ]; then exit 0; fi
|