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