forked from algorithm-archivists/algorithm-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_site.sh
executable file
·44 lines (36 loc) · 898 Bytes
/
update_site.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
#!/usr/bin/env bash
if [ $# -ge 1 ]; then
if [ $# -eq 2 ]; then
out_dir="$2"
else
if [ -z ${AAA_DIR+x} ]; then
echo "No output directory specified"
exit 1
fi
out_dir="$AAA_DIR"
fi
if [[ ! -d "$out_dir" ]]; then
echo "$out_dir is not a directory"
exit 1
fi
gitbook build . /tmp/algorithm-archivists.github.io
if [ $? -ne 0 ]; then
echo "Failed to build the book"
exit 1
fi
cd "$out_dir"
git reset --hard && \
git clean -dfx && \
git pull origin master
if [ $? -ne 0 ]; then
echo "Failed to prepare repository"
exit 1
fi
cp -r /tmp/algorithm-archivists.github.io/* .
rm -r /tmp/algorithm-archivists.github.io
git add .
git commit -m "$1"
git push origin master
else
echo "No commit message specified"
fi