diff options
| author | verdant <im@verdant.ee> | 2026-07-25 00:54:48 +0800 |
|---|---|---|
| committer | verdant <im@verdant.ee> | 2026-07-25 00:54:48 +0800 |
| commit | f93ae55a1a47462bb43b1785b9e30731dc47c38c (patch) | |
| tree | c4a76e0e821d94c1095c7594d55e2ec7db25d776 /publish.sh | |
| parent | c84efff2b85e5bdc1d08dcecbe1896548027f56c (diff) | |
| download | blog-f93ae55a1a47462bb43b1785b9e30731dc47c38c.tar.gz blog-f93ae55a1a47462bb43b1785b9e30731dc47c38c.zip | |
Add interactive confirmation before publishing
Diffstat (limited to 'publish.sh')
| -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 . |
