on develop help sign in
gogol/script/travis-documentation
61 lines 1.4 kB history raw
1#!/usr/bin/env bash
3set -euo pipefail
5if [ "$TRAVIS_BRANCH" != "develop" ]; then
6 echo "Ignoring documentation build for branch '$TRAVIS_BRANCH'."
7 exit 0
8fi
10if [ -z "$DOC_TOKEN" ]; then
11 echo "Ignoring documentation build due to missing token."
12 exit 0
13fi
15DOC_REF=github.com/brendanhay/gogol-doc.git
16GHCVER=${GHCVER?"GHCVER needs to be set."}
17BUILD_ID=${TRAVIS_BUILD_ID:-1}
18BUILD_NUMBER=${TRAVIS_BUILD_NUMBER:-1}
20path=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
22$path/travis-timeout \
23 stack --no-terminal --skip-ghc-check --stack-yaml stack-$GHCVER.yaml \
24 build --fast -j2 --haddock --no-haddock-deps \
25 gogol gogol-core
27output=doc
29cp -R $(stack path --local-doc-root) $output
32 cat <<-HTML
33 <!DOCTYPE html>
34 <h2>Gogol Library Documentation</h2>
35 <h4>Build <a href="https://travis-ci.org/brendanhay/gogol/builds/${BUILD_ID}">#${BUILD_NUMBER}</a>, GHC ${GHCVER}</h4>
36 <ul>
37HTML
39 for dir in $(ls -d $output/*/); do
40 file=$(basename $dir)
41 cat <<-HTML
42 <li><a href="${file}/index.html">${file}</a></li>
43HTML
44 done
46 cat <<-HTML
47 </ul>
48HTML
49} > $output/index.html
51cd $output
53git init
55git config user.name "Brendan Hay"
56git config user.email "brendan.g.hay@gmail.com"
58git add .
59git commit -m "Travis CI documentation deploy $BUILD_NUMBER"
61git push --force --quiet "https://${DOC_TOKEN}@${DOC_REF}" master:gh-pages > /dev/null 2>&1