-
Notifications
You must be signed in to change notification settings - Fork 2
/
publish.sh
executable file
·63 lines (50 loc) · 1.08 KB
/
publish.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
BRANCH="gh-pages"
PAGE="html/index.html"
TARGET="./index.html"
DATE=`date`
# checkout to gh-pages
git checkout -B $BRANCH
git pull origin $BRANCH
if [ $? -eq 0 ]; then
echo "[DONE] CHECKOUT TO '$BRANCH'"
else
echo "[FAIL] CHECKOUT TO '$BRANCH'"
exit 0
fi
# merge & adjust page resource path & output to ./index.html
git merge master
sed "s/\.\.\/css/\.\/css/g; s/\.\.\/js/\.\/js/g" $PAGE > $TARGET
echo '<!-- '$DATE' -->' >> $TARGET
if [ $? -eq 0 ]; then
echo "[DONE] MERGE CHANGE & PROCESS PAGE $PAGE"
else
echo "[FAIL] MERGE CHANGE & PROCESS PAGE $PAGE"
exit 0
fi
# add & commit change
git add $TARGET
git commit -m "AUTO PUBLISH @ $DATE"
if [ $? -eq 0 ]; then
echo "[DONE] COMMIT CHANGE"
else
echo "[FAIL] COMMIT CHANGE"
exit 0
fi
# push
git push origin $BRANCH
if [ $? -eq 0 ]; then
echo "[DONE] PUSH"
else
echo "[FAIL] PUSH"
exit 0
fi
# checkout back to master
git checkout master
if [ $? -eq 0 ]; then
echo "[DONE] CHECKOUT BACK TO 'master'"
else
echo "[FAIL] CHECKOUT BACK TO 'master'"
exit 0
fi
echo "PUBLISH DONE."