/
docs
executable file
·41 lines (32 loc) · 999 Bytes
/
docs
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
#!/usr/bin/env bash
#
# Builds the documentation and publishes it to gh-pages branch
#
set -euo pipefail
function cleanup {
rm -f .git/credentials
}
trap cleanup EXIT
PROJECT="jsond-validator"
DOCS_BUILD="docs"
DOCS_REPO="tmp/docs"
rm -rf $DOCS_BUILD $DOCS_REPO
# clone the gh-pages branch
git clone -v --branch gh-pages https://github.com/avaly/$PROJECT.git $DOCS_REPO
# generate the docs
node_modules/.bin/jsdoc -c jsdoc.json --verbose
VERSION=$(ls $DOCS_BUILD/$PROJECT/ | sort -n | head -1)
cd $DOCS_BUILD/$PROJECT/$VERSION
rsync -rt --exclude=".git" . ../../../$DOCS_REPO
cd ../../../
# setup git credentials in gh-pages repository
cd $DOCS_REPO
git config credential.helper "store --file=.git/credentials"
echo "https://${GH_TOKEN}:@github.com" > .git/credentials
git config user.name "TravisCI"
git config user.email "ci@travis-ci.org"
# commit & push docs
git add --all .
git commit -m "Documentation update for ${TRAVIS_COMMIT}"
git --no-pager log -n 3
git push -f origin gh-pages