-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·43 lines (35 loc) · 1013 Bytes
/
Copy pathdeploy.sh
File metadata and controls
executable file
·43 lines (35 loc) · 1013 Bytes
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
#!/bin/bash
set -x
set -e
MESSAGE=$1
# update blog in blog-source repo
NOTE_NAME="linux-notes"
BLOG_SOURCE_DIR="../blog-source/${NOTE_NAME}"
MASTER_DIR="$(pwd)"
GHPAGE_DIR="${MASTER_DIR}/gh-pages"
# clean and copy blog
rm -fr $(ls | grep -v -E 'node_modules|book.json|README.md|SUMMARY.md|.gitignore|LICENSE|gh-pages|deploy.sh|deploy_source.sh')
cp -fr ${BLOG_SOURCE_DIR}/* ./
# clean GHPAGE_DIR
if [ ! -d $GHPAGE_DIR ];then
git clone -b gh-pages https://github.com/huweihuang/${NOTE_NAME}.git gh-pages
fi
rm -fr ${GHPAGE_DIR}/*
# build
gitbook build
# copy _book to GHPAGE_DIR
cp -fr ${MASTER_DIR}/_book/* ${GHPAGE_DIR}
cp -fr ${MASTER_DIR}/README.md ${GHPAGE_DIR}
cp -fr ${MASTER_DIR}/SUMMARY.md ${GHPAGE_DIR}
if [ $2 = "dry-run" ];then
echo "gitbook server dry run"
gitbook serve
else
# git commit
cd ${GHPAGE_DIR}
git add --all
git config user.name huweihuang
git config user.email huweihuang@foxmail.com
git commit -m "${MESSAGE}"
git push origin gh-pages
fi