|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# ----------------------------------------------------------------------- |
| 4 | +# When pushing to a pull request on GitHub, Travis does two builds: |
| 5 | +# (1) One for the pull request itself. In this case, $TRAVIS_PULL_REQUEST |
| 6 | +# is 'false' and $TRAVIS_BRANCH contains the branch name |
| 7 | +# (2) One to *simulate* a merge with master. In this case, $TRAVIS_PULL_REQUEST |
| 8 | +# is the pull ID number and $TRAVIS_BRANCH = 'master' |
| 9 | +# |
| 10 | +# Read more about Travis environment variables -- |
| 11 | +# http://docs.travis-ci.com/user/ci-environment/ |
| 12 | +# ----------------------------------------------------------------------- |
| 13 | + |
| 14 | +# Only build test table if $TRAVIS_PULL_REQUEST is false |
| 15 | +[ "${TRAVIS_PULL_REQUEST}" != "false" ] && exit 0 |
| 16 | + |
| 17 | +git config --global user.name "cpsievert" |
| 18 | +git config --global user.email "[email protected]" |
| 19 | + |
| 20 | +# Since Travis does `git clone --branch=$TRAVIS_BRANCH --depth=50`, |
| 21 | +# we can't simply `git checkout master`. As far as I can tell, we are |
| 22 | +# forced to re-clone -- https://gist.github.com/cpsievert/698c7f1404f972782e71 |
| 23 | + |
| 24 | +cd .. |
| 25 | +rm -rf plotly/ |
| 26 | +git clone https://github.com/ropensci/plotly.git |
| 27 | +cd plotly |
| 28 | +echo "user,SHA1,label" >> ../code_commits.csv |
| 29 | +echo "ropensci,`git rev-parse HEAD`,master" >> ../code_commits.csv |
| 30 | +git checkout $TRAVIS_BRANCH |
| 31 | +echo "ropensci,`git rev-parse HEAD`,${TRAVIS_BRANCH}" >> ../code_commits.csv |
| 32 | +Rscript -e "devtools::install()" |
| 33 | + |
| 34 | +cd .. |
| 35 | +git clone https://github.com/ropensci/plotly-test-table.git |
| 36 | +cd plotly-test-table |
| 37 | +git checkout gh-pages |
| 38 | + |
| 39 | +mv ../code_commits.csv . |
| 40 | +cat code_commits.csv |
| 41 | +make |
| 42 | + |
| 43 | +# add, commit, push to gh-pages branch of plotly-test-table |
| 44 | +git add tables/*/*.html data/*/*.png |
| 45 | +git commit -a -m "Travis build number ${TRAVIS_BUILD_NUMBER} of ${TRAVIS_REPO_SLUG}" |
| 46 | +# This post explains how this works -- http://rmflight.github.io/posts/2014/11/travis_ci_gh_pages.html |
| 47 | +GH_REPO="@github.com/ropensci/plotly-test-table.git" |
| 48 | +FULL_REPO="https://${GH_TOKEN}${GH_REPO}" |
| 49 | +git pull $FULL_REPO gh-pages |
| 50 | +git push $FULL_REPO gh-pages |
0 commit comments