发布脚本:EzHub 走 HTTPS+令牌推送(SSH 还没配好)

EzHub 的 SSH 公钥在服务端一直被拒(Permission denied),
但令牌有 push 权限。所以发布脚本里 EzHub 改用
HTTPS + 令牌推,令牌只在进程内拼进 URL,不写进 .git/config。

顺带加了增量推送脚本 ezhub_push_all.py:
一次性推 44 个提交 = 117 MB,被 EzHub 的 nginx 413 拦了。
Git 推送是增量的,逐个提交推每包就小得多 —— 实测 44 个全部推成功。
脚本会先探测远端进度,只推缺的,并且对网络抖动自动重试。
This commit is contained in:
xmz7891
2026-10-07 12:32:11 +08:00
parent 9f9db53a06
commit f200240730
4 changed files with 360 additions and 2 deletions
+18 -2
View File
@@ -324,12 +324,28 @@ def main() -> int:
return 0
# ---- 1. 推代码 ----
# EzHub 的 SSH 密钥在用户那边还没配对成功(服务端拒绝本机公钥),
# 但令牌有 push 权限,所以走 HTTPS + 令牌推。
# 令牌只在这次进程里拼进 URL,不写进 .git/config。
print()
print(" 二、推代码")
for name, info in PLATFORMS.items():
r = run_git(["push", info["remote"], "main"])
if name == "ezhub":
url = ("https://%s:%s@%s/%s/%s.git"
% ("xmz", ezhub_token, "git.261826.xyz", "xmz", "ykxmz"))
r = subprocess.run([GIT, "push", url, "main"], cwd=str(ROOT),
capture_output=True, text=True,
encoding="utf-8", errors="replace",
timeout=900)
raw = (r.stderr or r.stdout or "")
else:
r = run_git(["push", info["remote"], "main"])
raw = (r.stderr or r.stdout or "")
ok = r.returncode == 0
tail = ((r.stderr or r.stdout or "").strip().splitlines() or [""])[-1]
# 输出里可能带令牌,打码
safe = raw.replace(ezhub_token, "***") if ezhub_token else raw
tail = (safe.strip().splitlines() or [""])[-1]
print(" %-6s %s %s" % (name, "✓" if ok else "✗", tail[:90]))
if not ok:
print(" (代码没推上去,先修这个再建发行版)")