travis-deploy.sh 760 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # Based on https://github.com/hydrabolt/discord.js-site/blob/master/deploy/deploy.sh
  3. set -e
  4. if [ "$TRAVIS_BRANCH" != "master" -o -n "$TRAVIS_TAG" -o "$TRAVIS_PULL_REQUEST" != "false" ]; then
  5. echo -e "Not building for a non master branch push - building without deploying."
  6. npm run docs
  7. exit 0
  8. fi
  9. echo -e "Building for a master branch push - building and deploying."
  10. REPO=$(git config remote.origin.url)
  11. SHA=$(git rev-parse --verify HEAD)
  12. TARGET_BRANCH="gh-pages"
  13. git clone $REPO dist -b $TARGET_BRANCH
  14. npm run docs
  15. rsync -vau docs/ dist/
  16. cd dist
  17. git add --all .
  18. git config user.name "Travis CI"
  19. git config user.email "${COMMIT_EMAIL}"
  20. git commit -m "Docs build: ${SHA}" || true
  21. git push "https://${GH_TOKEN}@${GH_REF}" $TARGET_BRANCH