push_latest_docs.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # Deploy the gh-pages branch, adapted from
  3. # https://github.com/google/dagger/blob/master/util/generate-latest-docs.sh
  4. # See also http://stackoverflow.com/a/22977235 for ssh-based deploy.
  5. set -e
  6. # Only push if we've just committed to google/closure-library:master.
  7. # Start by decrypting the deploy password, and pre-populate GitHub's
  8. # RSA key to avoid needing to manually accept it when connecting.
  9. if [ "$TRAVIS_REPO_SLUG" == "google/closure-library" -a \
  10. "$TRAVIS_PULL_REQUEST" == "false" -a \
  11. "$TRAVIS_BRANCH" == "master" ]; then
  12. # If we're on travis, use a secure $deploy_password
  13. if [ -n "$deploy_password" ]; then
  14. touch scripts/ci/deploy
  15. chmod 600 scripts/ci/deploy
  16. openssl aes-256-cbc -k "$deploy_password" -d -a \
  17. -in scripts/ci/deploy.enc -out scripts/ci/deploy \
  18. &> /dev/null
  19. echo -e "Host github.com\n IdentityFile $PWD/scripts/ci/deploy" > ~/.ssh/config
  20. echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6Tb
  21. Qa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsd
  22. lLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+S
  23. e8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOz
  24. QgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA
  25. 8VJiS5ap43JXiUFFAaQ==" | sed 's/^ *//' | tr -d '\n' > ~/.ssh/known_hosts
  26. fi
  27. # Push the commit and delete the repo.
  28. export GIT_WORK_TREE="$GH_PAGES"
  29. export GIT_DIR="$GH_PAGES/.git"
  30. git push -fq origin gh-pages > /dev/null
  31. rm -f scripts/ci/deploy
  32. rm -rf "$GH_PAGES"
  33. echo "Published gh-pages."
  34. fi