File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55# Published under MIT License
66
77
8+ CMD=" JEKYLL_ENV=production bundle exec jekyll b"
9+ DEST=$( realpath ' _site' )
10+
811help () {
912 echo " Usage:"
1013 echo
@@ -25,18 +28,14 @@ init() {
2528 fi
2629
2730 if [[ -d _site ]]; then
28- rm -rf _site
29- fi
30-
31- if [[ -d ../.chirpy-cache ]]; then
32- rm -rf ../.chirpy-cache
31+ jekyll clean
3332 fi
3433
35- mkdir ../.chirpy-cache
36- cp -r * ../.chirpy-cache
37- cp -r .git ../.chirpy-cache
34+ temp=$( mktemp -d)
35+ cp -r * $temp
36+ cp -r .git $temp
37+ mv $temp .container
3838
39- mv ../.chirpy-cache .container
4039}
4140
4241
@@ -49,9 +48,6 @@ check_unset() {
4948}
5049
5150
52- CMD=" JEKYLL_ENV=production bundle exec jekyll b"
53- DEST=` realpath " ./_site" `
54-
5551while [[ $# -gt 0 ]]
5652do
5753 opt=" $1 "
7268 ;;
7369 -d|--destination)
7470 check_unset $2
75- if [[ -d $2 ]]; then
76- rm -rf $2
77- fi
78- DEST=$2
71+ DEST=$( realpath $2 )
7972 shift ;
8073 shift ;
8174 ;;
9083 esac
9184done
9285
86+
9387init
9488
9589cd .container
9690
9791echo " $ cd $( pwd) "
9892python _scripts/py/init_all.py
9993
100- CMD+=" -d $DEST "
94+ CMD+=" -d ${ DEST} "
10195echo " \$ $CMD "
10296eval $CMD
97+ echo -e " \nBuild success, the site files placed in '${DEST} '."
98+
99+ if [[ -d ${DEST} /.git ]]; then
100+
101+ if [[ ! -z $( git -C $DEST status -s) ]]; then
102+ git -C $DEST add .
103+ git -C $DEST commit -m " [Automation] Update site files." -q
104+ echo -e " \nPlease push the changes of '$( realpath $DEST ) ' to remote master branch.\n"
105+ fi
103106
104- echo " $( date ) - Build success, the Site files placed in _site. "
107+ fi
105108
106109cd .. && rm -rf .container
Original file line number Diff line number Diff line change @@ -32,15 +32,10 @@ init() {
3232 rm -rf .container
3333 fi
3434
35- if [[ -d ../.chirpy-cache ]]; then
36- rm -rf ../.chirpy-cache
37- fi
38-
39- mkdir ../.chirpy-cache
40- cp -r * ../.chirpy-cache
41- cp -r .git ../.chirpy-cache
42-
43- mv ../.chirpy-cache .container
35+ temp=$( mktemp -d)
36+ cp -r * $temp
37+ cp -r .git $temp
38+ mv $temp .container
4439
4540 trap cleanup INT
4641}
You can’t perform that action at this time.
0 commit comments