diff options
| -rwxr-xr-x | publish.sh | 37 |
1 files changed, 34 insertions, 3 deletions
@@ -1,10 +1,41 @@ #!/bin/bash -rm .hugo_build.lock +ask() { + local prompt="$1" + local answer + while true; do + read -p "$prompt (y/n) " answer + case "$answer" in + [Yy]* ) return 0;; + [Nn]* ) return 1;; + * ) echo "请输入 y 或 n";; + esac + done +} + +cd ~/blog/ || exit 1 + +echo "发布前确认:" +if ! ask "确认填写日期正确吗?"; then + echo "已取消发布。" + exit 0 +fi +if ! ask "确认文章标题正确吗?"; then + echo "已取消发布。" + exit 0 +fi +if ! ask "确认文章没有错别字了吗?"; then + echo "已取消发布。" + exit 0 +fi +if ! ask "确认没有发布草稿吗?"; then + echo "已取消发布。" + exit 0 +fi + +rm -f .hugo_build.lock -# 执行 Hugo 构建和部署 commit_date=$(date +"%Y-%m-%d %H:%M:%S") -cd ~/blog/ hugo --cleanDestinationDir --gc --minify cd ~/blog/public || exit 1 git add . |
