-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathupdate-gh-pages
executable file
·82 lines (60 loc) · 2.14 KB
/
update-gh-pages
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# ----- Early exit check
if [ "$TRAVIS_BRANCH" != "" ]; then
# Exit if we are running inside travis but not on the iOS scheme
if [ "$SCHEME" != "iOS" ]; then
echo " <== Early exit - SCHEME='$SCHEME'"
exit 0
fi
fi
# ----- Configuration
ORGANISATION=ReSwift
NAME=ReactiveReSwift
BRANCH=$([ "$TRAVIS_BRANCH" == "" ] && echo "master" || echo "$TRAVIS_BRANCH")
SHA=`git rev-parse --verify HEAD --short`
REPO=`git config remote.origin.url`
TMP=Docs/tmp
CHECKOUT_PATH=Docs/output
OUTPUT_PATH=$CHECKOUT_PATH/$BRANCH
# ----- Clone the GitHub pages repo if required
echo " ==> Updating documentation for '$BRANCH' branch"
if [ -d "$CHECKOUT_PATH" ]; then
echo " ==> Update: gh-pages -> $CHECKOUT_PATH"
git -C "$CHECKOUT_PATH" pull origin gh-pages
else
echo " ==> Checkout: gh-pages -> $CHECKOUT_PATH"
git clone --branch gh-pages "$REPO" "$CHECKOUT_PATH"
fi
if [ "$TRAVIS_BRANCH" != "" ]; then
echo " ==> Install: jazzy"
gem install --no-rdoc --no-ri jazzy
fi
echo " ==> Generate documentation"
.scripts/generate-docs "$BRANCH" "$OUTPUT_PATH"
# ----- Travis Documentation updater
# Exit if not running from travis
if [ "$TRAVIS_BRANCH" == "" ]; then exit; fi
if [ "$SCHEME" != "iOS" ]; then exit; fi
pushd "$CHECKOUT_PATH"
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"
# Exit if there are no changes to the documentation
echo " ==> Check for documentation changes"
CHANGE_SET=$(git status -s)
if [ "$CHANGE_SET" == "" ]; then
echo " <== No changes to the output on this push; exiting."
exit 0
fi
# Exit if only the docset archive has changed (it always changes)
if [ "$CHANGE_SET" == " M $BRANCH/docsets/$NAME.tgz" ]; then
echo " <== Only the docset archive changed on this push; exiting."
exit 0
fi
echo " ==> Stage changes"
git add -A "$BRANCH"
echo " ==> Commit changes"
git commit -m "[$BRANCH $SHA] Regenerate documentation"
echo " ==> Push changes -> '$REPO'"
git push -q "https://[email protected]/$ORGANISATION/$NAME.git" gh-pages
echo " <== All done 👊"
popd