|
| 1 | +#! /usr/bin/env bash |
| 2 | + |
| 3 | +# Copied from github.com/sympy/sympy |
| 4 | +# |
| 5 | +# This file automatically deploys changes to http://synthicity.github.io/activitysim/. |
| 6 | +# This will only happen when building a non-pull request build on the master |
| 7 | +# branch of ActivitySim. |
| 8 | +# It requires an access token which should be present in .travis.yml file. |
| 9 | +# |
| 10 | +# Following is the procedure to get the access token: |
| 11 | +# |
| 12 | +# $ curl -X POST -u <github_username> -H "Content-Type: application/json" -d\ |
| 13 | +# "{\"scopes\":[\"public_repo\"],\"note\":\"token for pushing from travis\"}"\ |
| 14 | +# https://api.github.com/authorizations |
| 15 | +# |
| 16 | +# It'll give you a JSON response having a key called "token". |
| 17 | +# |
| 18 | +# $ gem install travis |
| 19 | +# $ travis encrypt -r sympy/sympy GH_TOKEN=<token> env.global |
| 20 | +# |
| 21 | +# This will give you an access token("secure"). This helps in creating an |
| 22 | +# environment variable named GH_TOKEN while building. |
| 23 | +# |
| 24 | +# Add this secure code to .travis.yml as described here http://docs.travis-ci.com/user/encryption-keys/ |
| 25 | + |
| 26 | +# Exit on error |
| 27 | +set -e |
| 28 | + |
| 29 | +ACTUAL_TRAVIS_JOB_NUMBER=`echo $TRAVIS_JOB_NUMBER| cut -d'.' -f 2` |
| 30 | + |
| 31 | +if [ "$TRAVIS_REPO_SLUG" == "synthicity/activitysim" ] && \ |
| 32 | + [ "$TRAVIS_BRANCH" == "master" ] && \ |
| 33 | + [ "$TRAVIS_PULL_REQUEST" == "false" ] && \ |
| 34 | + [ "$ACTUAL_TRAVIS_JOB_NUMBER" == "1" ]; then |
| 35 | + |
| 36 | + echo "Installing dependencies" |
| 37 | + conda install --yes --quiet sphinx numpydoc |
| 38 | + pip install sphinx_rtd_theme |
| 39 | + |
| 40 | + echo "Building docs" |
| 41 | + cd docs |
| 42 | + make clean |
| 43 | + make html |
| 44 | + |
| 45 | + cd ../../ |
| 46 | + echo "Setting git attributes" |
| 47 | + git config --global user.email "[email protected]" |
| 48 | + git config --global user.name "Matt Davis" |
| 49 | + |
| 50 | + echo "Cloning repository" |
| 51 | + git clone --quiet --single-branch --branch=gh-pages https://${GH_TOKEN}@github.com/synthicity/activitysim.git gh-pages > /dev/null 2>&1 |
| 52 | + |
| 53 | + cd gh-pages |
| 54 | + rm -rf * |
| 55 | + cp -R ../activitysim/docs/_build/html/* ./ |
| 56 | + git add -A . |
| 57 | + |
| 58 | + git commit -am "Update dev doc after building $TRAVIS_BUILD_NUMBER" |
| 59 | + echo "Pushing commit" |
| 60 | + git push -fq origin gh-pages > /dev/null 2>&1 |
| 61 | +fi |
0 commit comments