forked from gorpc101/gorpc101
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-gitbook2ghpages.sh
executable file
·45 lines (38 loc) · 1.08 KB
/
publish-gitbook2ghpages.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
#!/bin/bash -e
rm -rf docs
USE_DOCKER=0
# Parse command line options
while getopts "dh" opt; do
case "$opt" in
d) # use docker container to build
USE_DOCKER=1
echo "docker flag set"
;;
h) # Display help
echo "Usage: ./publish-gitbook2ghpages.sh [-d] [-h]"
echo "-d: use docker container hitzhangjie/gitbook-cli to build pages"
echo " otherwise, use native gitbook to build pages"
echo "-h: show the help message"
exit 0
;;
*) # Invalid option
echo "Error: Invalid option $opt"
exit 1
;;
esac
done
if [ $USE_DOCKER -eq 1 ]
then
docker run --rm -v $(pwd -P):/root/gitbook hitzhangjie/gitbook-cli:latest gitbook build . docs
else
gitbook build . docs
fi
sudo chown -R zhangjie:zhangjie docs
mv docs/.gitbook/assets docs/assets
rm -rf docs/.gitbook
find docs/ -iname "*.html" | xargs sed -i 's/.gitbook\/assets/assets/g'
find docs/ -iname "*.html" | xargs sed -i 's/\\_/_/g'
find docs/ -iname "*.html" | xargs sed -i 's/\/_/_/g'
git add docs
git cc -m 'publish book'
git push