-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
generate-api.sh
executable file
·63 lines (50 loc) · 1.7 KB
/
generate-api.sh
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
62
63
#!/bin/sh
# where's the source files?
SRC='src'
# for what branch to trigger
BRANCH='master'
# github repo
REPO='splitbrain/php-archive'
# ---- About -------------------------------------------------------
#
# This script use apigen to generate the documentation for the
# repository configured above. When run locally, the documentation
# will be placed in the 'docs' folder.
# However this script can also be run from travis. This requires
# the setup of a secret token as described at http://bit.ly/1MNbPn0
#
# Additional configuration can be done within an apigen.neon file
#
# ---- no modifications below ---------------------------------------
# when on travis, build outside of repository, otherwise locally
if [ -z "$TRAVIS" ]; then
DST='docs'
else
DST='../gh-pages'
if [ "$TRAVIS_PHP_VERSION" != '7.2' ]; then exit; fi
if [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then exit; fi
if [ "$TRAVIS_PULL_REQUEST" != 'false' ]; then exit; fi
if [ -z "$GH_TOKEN" ]; then
echo "GH_TOKEN not set! See: http://bit.ly/1MNbPn0"
exit
fi
fi
# Get ApiGen.phar
wget http://www.apigen.org/apigen.phar -O apigen.phar
# Generate SDK Docs
php apigen.phar generate --template-theme="bootstrap" -s $SRC -d $DST
### if we're not on travis, we're done
if [ -z "$TRAVIS" ]; then exit; fi
# go to the generated docs
cd $DST || exit
# Set identity
git config --global user.email "[email protected]"
git config --global user.name "Travis"
# Add branch
git init
git remote add origin https://${GH_TOKEN}@github.com/${REPO}.git > /dev/null
git checkout -B gh-pages
# Push generated files
git add .
git commit -m "Docs updated by Travis"
git push origin gh-pages -fq > /dev/null