From 84b463041c2f63d45299bf103cd20fd336bac0ba Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 6 Oct 2014 09:15:53 +0100 Subject: [PATCH] Update travis build for docs sync --- .travis.yml | 13 +++++++--- src/main/asciidoc/ghpages.sh | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100755 src/main/asciidoc/ghpages.sh diff --git a/.travis.yml b/.travis.yml index 48fcedd..dfe3986 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,14 @@ language: java -install: mvn install -q -U -DskipTests=true -Dmaven.test.redirectTestOutputToFile=true +before_install: git config user.name "$GIT_NAME" && git config user.email "$GIT_EMAIL" + && git config credential.helper "store --file=.git/credentials" && echo "https://$GH_TOKEN:@github.com" > .git/credentials +install: + - mvn install -q -U -DskipTests=true -Dmaven.test.redirectTestOutputToFile=true + - ./src/main/asciidoc/ghpages.sh script: mvn --settings .settings.xml deploy -nsu -Dmaven.test.redirectTestOutputToFile=true env: global: - - secure: VsSFz5DO1BcI6Q9Hr/216DYLfo4FzZqD7LFZDa1VJqZUAtgy6/c0Z5E0vaIJOefpap/MoAHlNDloIwwtDIqCy4NLIUzzqZwmMeT+1hPdbLylQ61qr6UY34kMBmL00wH83iKZ65Z5FR5yhSjT0sNwfIDwEmt9etEsx64/vPNkcCI= - - secure: MThA8XhwSMcL8zv62olufrvYRTecnujimz0qZccjyMrpyZ5A6mWtHnpAIY4nYEoYNu+kAWPceaqO6bKn6wVv1xzP7ddJRxV5MmPkqt2S/WbqS1hp6gkOfclPdqRzz1NjEuAG8qu6m9EEn0NLsHhSfXl3mVz4huD0UUW+2AjUeN8= + - GIT_NAME="Dave Syer" + - GIT_EMAIL=dsyer@pivotal.io + - secure: VsSFz5DO1BcI6Q9Hr/216DYLfo4FzZqD7LFZDa1VJqZUAtgy6/c0Z5E0vaIJOefpap/MoAHlNDloIwwtDIqCy4NLIUzzqZwmMeT+1hPdbLylQ61qr6UY34kMBmL00wH83iKZ65Z5FR5yhSjT0sNwfIDwEmt9etEsx64/vPNkcCI= + - secure: MThA8XhwSMcL8zv62olufrvYRTecnujimz0qZccjyMrpyZ5A6mWtHnpAIY4nYEoYNu+kAWPceaqO6bKn6wVv1xzP7ddJRxV5MmPkqt2S/WbqS1hp6gkOfclPdqRzz1NjEuAG8qu6m9EEn0NLsHhSfXl3mVz4huD0UUW+2AjUeN8= + - secure: uM3piUpKZ018xCqVTlra1Io+nmV/Q79o3i6QzApqlQaIZBMxJI5M31wU3pHTkWGYfbi7H4+ehiRwi9knMxcPHb7o6nMyr+6tju3h3zUyScCh4prnC6v5JeyJmkA9aMG3s632l0T5vrwIoEonI6XxE0xd0ZuljQl1/vNXs9QUD5Y= diff --git a/src/main/asciidoc/ghpages.sh b/src/main/asciidoc/ghpages.sh new file mode 100755 index 0000000..67da0d2 --- /dev/null +++ b/src/main/asciidoc/ghpages.sh @@ -0,0 +1,46 @@ +#!/bin/bash -x + +git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'` + +if ! (git remote set-branches --add origin gh-pages && git fetch -q); then + echo "No gh-pages, so not syncing" + exit 0 +fi + +if ! [ -d target/generated-docs ]; then + echo "No gh-pages sources in target/generated-docs, so not syncing" + exit 0 +fi + +# Stash any outstanding changes +################################################################### +git diff-index --quiet HEAD +dirty=$? +if [ "$dirty" != "0" ]; then git stash; fi + +# Switch to gh-pages branch to sync it with master +################################################################### +git checkout gh-pages + +for f in target/generated-docs/*; do + file=${f#target/generated-docs/*} + if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then + # Not ignored... + cp -rf $f . + git add -A $file + fi +done + +git commit -a -m "Sync docs from master to gh-pages" + +# Uncomment the following push if you want to auto push to +# the gh-pages branch whenever you commit to master locally. +# This is a little extreme. Use with care! +################################################################### +git push origin gh-pages + +# Finally, switch back to the master branch and exit block +git checkout master +if [ "$dirty" != "0" ]; then git stash pop; fi + +exit 0