deploy_ghpages.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. #
  3. # Script for travis-ci to sync apidoc dir from master branch to gh-pages branch
  4. # based on :
  5. # * https://github.com/steveklabnik/automatically_update_github_pages_with_travis_example
  6. # * https://github.com/gemini-testing/gemini/pull/352/files
  7. set -o errexit -o nounset
  8. if [ "$TRAVIS_BRANCH" != "master" ] ; then
  9. echo "This commit was made against the $TRAVIS_BRANCH and not the master! No deploy!"
  10. exit 0
  11. fi
  12. rev=$(git rev-parse --short HEAD)
  13. repo=$(git config --local --get-all remote.origin.url | awk -F'[:/]' 'NF && NF-1 {print ($(NF-1)"/"$NF)}')
  14. echo -e "Starting to update gh-pages of ${repo} at ${rev}\n"
  15. # on Travis, can't optimize by cloning itself and define remote as upstream
  16. # travis> "attempt to fetch/clone from a shallow repository"
  17. # So need to do a full clone
  18. rm -Rf gh-pages
  19. git clone -b gh-pages --single-branch https://${GH_TOKEN}@github.com/${repo} gh-pages
  20. cd gh-pages
  21. rsync -avz --stats ../build/asciidoc/html5/. .
  22. git config --local user.email "[email protected]"
  23. git config --local user.name "Travis"
  24. git add -A .
  25. git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages at ${rev}"
  26. git push origin gh-pages
  27. cd ..
  28. rm -Rf gh-pages