Add gh pages to travis to sync docs

This commit is contained in:
Dave Syer
2014-10-05 14:16:28 +01:00
parent da7522c25a
commit 1fe42c1fe1
2 changed files with 49 additions and 6 deletions

View File

@@ -1,8 +1,5 @@
language: java
before_install: git clone https://github.com/dsyer/spring-security-rsa tmp && (cd tmp && mvn install -DskipTests=true)
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: aomAMudvGhboHcPQDfZ9xFv0ThFMD53aCbX8f9DE0X6GudmdG4fcI02BDfIwFiDG8TG0DZl5brHCzbfgvylNv+Z54GwhzrMytUGv3sn2Meal5bhHm6opjHARqKzNnV8IHRYTVAZbBZK/9eUWIyQtxEL+fmK3PtzlTRshT81hI8I=
- secure: YhCHblp6q9FF4kCB4OlvqVpmMjysObdFuioDstRdvCc7V5fpxwnaGlt46qXAEsYbbdAw4YTibFid9vwyGT/cqbmaq5q0l5qrxEbe/sOdM1TTnH4rLIDLdSdhub3J18WWxtHlF4NmhmR3XL0bOIWjNvgoLkPyc6acILn+8FBzC4c=

46
src/main/asciidoc/ghpages.sh Executable file
View File

@@ -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