> $BLOG_BASE/public/CNAME git add . msg="rebuilding site `date`" git commit -m "$msg" git push origin master # 完成 cd $BLOG_BASE echo "\n\nFinished""> > $BLOG_BASE/public/CNAME git add . msg="rebuilding site `date`" git commit -m "$msg" git push origin master # 完成 cd $BLOG_BASE echo "\n\nFinished""> > $BLOG_BASE/public/CNAME git add . msg="rebuilding site `date`" git commit -m "$msg" git push origin master # 完成 cd $BLOG_BASE echo "\n\nFinished"">
#!/bin/sh
export BLOG_BASE="/blog" # Hugo path
export CNAME="blog.example.com" # CNAME

echo -e "\\033[0;32mDeploying updates to GitHub...\\033[0m"
# 備份 pubilc
echo -e "Back up..."
cp -R $BLOG_BASE/public/[^.]* $BLOG_BASE/backup/public_backup/
cp -R $BLOG_BASE/content/[^.]* $BLOG_BASE/backup/content_backup/

# 移除舊的
echo -e "\\033[1;31mDelete file...\\033[0m"
rm -rf $BLOG_BASE/public/[^.]*

# 建立新的 pubilc
echo -e "build..."
cd $BLOG_BASE && hugo
cp -R $BLOG_BASE/content/[^.]* $BLOG_BASE/public/

# push 上 github
cd $BLOG_BASE/public
echo $CNAME >> $BLOG_BASE/public/CNAME

git add .
msg="rebuilding site `date`"
git commit -m "$msg"
git push origin master
# 完成
cd $BLOG_BASE
echo "\\n\\nFinished"