www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

auto-push-gh-pages.sh (2371B)


      1 #!/bin/sh
      2 set -e
      3 set +x
      4 if test "$(git config remote.origin.url)" != "https://github.com/jsmaniac/phc-thesis.git"; then
      5   echo "Not on official repo, will not deploy gh-pages."
      6 elif test "$TRAVIS_PULL_REQUEST" != "false"; then
      7   echo "This is a Pull Request, will not deploy gh-pages."
      8 elif test "$TRAVIS_BRANCH" != "master"; then
      9   echo "Not on master branch (TRAVIS_BRANCH = $TRAVIS_BRANCH), will not deploy gh-pages."
     10 elif test -z "${encrypted_8fdb34b09f5e_key:-}" -o -z "${encrypted_8fdb34b09f5e_iv:-}"; then
     11   echo "Travis CI secure environment variables are unavailable, will not deploy gh-pages."
     12 else
     13   set -x
     14   echo "Automatic push to gh-pages"
     15 
     16   # Git configuration:
     17   git config --global user.name "$(git log --format="%aN" HEAD -1) (Travis CI automatic commit)"
     18   git config --global user.email "$(git log --format="%aE" HEAD -1)"
     19 
     20   # SSH configuration
     21   mkdir -p ~/.ssh
     22   chmod 700 ~/.ssh
     23   set +x
     24   if openssl aes-256-cbc -K $encrypted_8fdb34b09f5e_key -iv $encrypted_8fdb34b09f5e_iv -in travis-deploy-key-id_rsa.enc -out travis-deploy-key-id_rsa -d >/dev/null 2>&1; then
     25     echo "Decrypted key successfully."
     26   else
     27     echo "Error while decrypting key."
     28   fi
     29   mv travis-deploy-key-id_rsa ~/.ssh/travis-deploy-key-id_rsa
     30   set -x
     31   chmod 600 ~/.ssh/travis-deploy-key-id_rsa
     32   set +x
     33   eval `ssh-agent -s`
     34   set -x
     35   ssh-add ~/.ssh/travis-deploy-key-id_rsa
     36 
     37   TRAVIS_GH_PAGES_DIR="$HOME/travis-gh-pages-$(date +%s)"
     38   if test -e $TRAVIS_GH_PAGES_DIR; then rm -rf $TRAVIS_GH_PAGES_DIR; fi
     39   mv -i doc $TRAVIS_GH_PAGES_DIR
     40   git init $TRAVIS_GH_PAGES_DIR
     41   #rm -f $TRAVIS_GH_PAGES_DIR/MathJax
     42   #mkdir $TRAVIS_GH_PAGES_DIR/MathJax
     43   #echo 'document.write("<script src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default\"></script>");' > $TRAVIS_GH_PAGES_DIR/MathJax/MathJax.js
     44   touch $TRAVIS_GH_PAGES_DIR/.nojekyll
     45   (cd $TRAVIS_GH_PAGES_DIR && git add -A . && git commit -m "Auto-publish to gh-pages") > commit.log || (cat commit.log && exit 1)
     46   (cd $TRAVIS_GH_PAGES_DIR && git log --oneline --decorate --graph -10)
     47   echo '(cd '"$TRAVIS_GH_PAGES_DIR"'; git push --force --quiet "git@github.com/jsmaniac/phc-thesis.git" master:gh-pages)'
     48   (cd $TRAVIS_GH_PAGES_DIR; git push --force --quiet "git@github.com:jsmaniac/phc-thesis.git" master:gh-pages >/dev/null 2>&1) >/dev/null 2>&1 # redirect to /dev/null to avoid showing credentials.
     49 fi