fix(deploy): receiver 改调构建仓自己的 build.sh——发布链执行源归一

- 架构债(20:31 事故根因层):receiver 此前执行工作树
  infra/deploy/build.sh,车道在途半成品状态可断生产链——改为
  build-repo/infra/deploy/build.sh(origin/main 硬跟版本),
  构建仓缺失时首克引导(匿名 clone)
- 双副本纪律入档头注:仓内源与 ~/docker_apps/blog/ 运行副本改一
  须同步二并 restart(systemd 跑的是运行副本,漂移即事故)
- 深意:构建脚本演化自此走 git 评审流,main=可部署铁律闭环

验证: 签名 POST 端到端实测(HMAC 构造无 git 污染):202 queued →
      90s 后 stamp=1fdd0cc;healthz 200;单元 active

Spec: none (发布链架构修正:单执行源切换+端到端实测)

Co-authored-by: GLM-5.3
This commit is contained in:
wait4xandGLM-5.3 committed 2026-10-25 21:12:48 +08:00
1 parent 0c569b0b31
commit 810cf44d3d
1 file changed
+17 -3
+17 -3
View File
@@ -8,6 +8,8 @@
ESA 只代理 80/443 vhost,该端口不对公网;HMAC 是硬门槛。
触发链:gitea push(main) → 本接收器验签 → build.sh → www-staging 更新。
部署形态:systemd 运行副本 ~/docker_apps/blog/webhook_receiver.py——改本文件
必须同步两份(仓内源 + 运行副本)并 restart 单元,漂移即事故。
常驻方式:systemd --user(blog-webhook.service);reboot 自启需一次性
`sudo loginctl enable-linger wait4x`(已列入上线检查单)。
"""
@@ -21,9 +23,21 @@ from pathlib import Path
PORT = 13021
SECRET_FILE = Path.home() / "docker_apps/gitea/webhook-secret.txt"
BUILD = Path.home() / "Code/Github/my-blog/infra/deploy/build.sh"
BUILD_REPO = Path.home() / "docker_apps/blog/build-repo"
BUILD_LOCK = threading.Lock()
# 构建脚本 = 构建仓自己的 origin/main 版本(架构修正 2026-10-25:此前指向
# 工作树副本,车道在途半成品状态会断生产链——20:31 事故实锤)。构建仓缺失时
# 首克引导(blog 仓公开,匿名 clone)。
def build_script() -> Path:
s = BUILD_REPO / "infra/deploy/build.sh"
if not s.exists():
subprocess.run(
["git", "clone", "https://git.wait4x.online/wait4x/blog.git", str(BUILD_REPO)],
check=True, capture_output=True,
)
return s
def read_secret() -> bytes:
return SECRET_FILE.read_text().strip().encode()
@@ -72,9 +86,9 @@ class Handler(BaseHTTPRequestHandler):
def _run_build(self) -> None:
with BUILD_LOCK:
subprocess.run(
["bash", str(BUILD)],
["bash", str(build_script())],
capture_output=True, timeout=1200,
cwd=str(BUILD.parent),
cwd=str(BUILD_REPO),
)
def log_message(self, fmt: str, *args: object) -> None: