This commit is contained in:
ming committed 2026-10-16 21:59:00 +08:00
1 parent d809dc41a9
commit e17fda59a3
2 files changed
+59 -3

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
#!/bin/sh
# 安装 git 钩子:提交后自动构建并上传网站。
# 用法:tools/install-hooks.sh
# 卸载:rm .git/hooks/post-commit(本脚本写入的内容带 "# blackwolf" 标记)
set -e
root=$(git rev-parse --show-toplevel)
hook="$root/.git/hooks/post-commit"
mkdir -p "$(dirname "$hook")"
cat > "$hook" <<'EOF'
#!/bin/sh
# blackwolf: 提交后自动部署(构建 + rsync 上传)
log="$(git rev-parse --show-toplevel)/.git/deploy.log"
echo "== $(date '+%F %T') post-commit deploy ==" >> "$log"
if make -s deploy >> "$log" 2>&1; then
echo "网站已更新(详见 .git/deploy.log)"
else
echo "网站部署失败,详见 .git/deploy.log" >&2
fi
EOF
chmod +x "$hook"
echo "已安装: $hook"
echo "以后 git commit 后会自动跑 make deploy(构建 + 上传)。"
echo "如需免密上传,请先把公钥装到服务器:"
echo " ssh-copy-id dwuser@drwater.net # 或手动追加 ~/.ssh/id_ed25519.pub"