-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdeploy.sh
executable file
·45 lines (34 loc) · 1006 Bytes
/
deploy.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
#!/bin/bash -e
# repository to fetch book content
deploy=https://github.com/hitzhangjie/debugger101.io
# build the book for Chinese version
book="book.zh"
# create a temporary folder and be sure to delete them when exit
tmpdir=$(mktemp -d)
trap 'sudo rm -rf "$tmpdir"' EXIT
builddir=$(mktemp -d)
trap 'sudo rm -rf "$builddir"' EXIT
# build the book and publish to github
printf "\033[0;32mDeploying updates to GitHub...\033[0m\n"
git clone $deploy $tmpdir
# deploy by `gitbook-cli` image
docker run --name gitbook --rm \
-v ${PWD}:/root/gitbook \
-v $builddir:$builddir \
hitzhangjie/gitbook-cli:latest \
gitbook build $book $builddir
# deploy by installed `gitbook-cli`
#gitbook build $book $builddir
# go to publishdir and commit
cp -rf $builddir/* $tmpdir/
# Commit changes.
cd $tmpdir
git add .
msg="rebuilding site $(date)"
if [ -n "$*" ]; then
msg="$*"
fi
git commit -m "$msg"
# Push source and build repos.
git push -f -u origin master
cd -