fix: 支持 test→prd 两级流转的自动合并与 synchronize 事件

1. 自动合并门槛过严
   上一版要求 PR 目标必须等于 managed_branch 才自动合并,
   这会让两级流转(feature -> test -> prd)的第一级永远合不进去。
   改为:目标命中任一检查分支即可自动合并。
   managed_branch 退化为「push 无 PR 时的对比基准」与默认值。

2. Gitea 的 PR 更新事件名是 synchronized
   Gitea webhook 的 payload.action 用 synchronized,
   只有它的 Actions runner 才会改写成 GitHub 风格的 synchronize。
   原先只认 synchronize,导致「PR 有新提交」永远不触发。
   现在两种拼写都接受。

验证(真实 webhook,非手工触发):
- feature -> test 开 PR:pull_request.opened 自动入队并审查
- 再推一个 commit:pull_request.synchronized 自动入队
- 无阻断问题 -> commit status success -> 自动 squash 合并,PR #4 已 merged
- 向未受保护分支推送会被正确过滤
This commit is contained in:
2026-09-20 14:54:33 +08:00
parent 34f2897888
commit ab509eee0d
3 changed files with 27 additions and 8 deletions
+7 -1
View File
@@ -216,9 +216,15 @@ async function handlePush(payload, cfg) {
return { queued: 1, jobId };
}
// Gitea's webhook payload uses "synchronized"; only its Actions runner rewrites
// that to the GitHub-style "synchronize", so accept every spelling.
const PR_ACTIONS = new Set([
"opened", "reopened", "synchronize", "synchronized", "ready_for_review",
]);
async function handlePullRequest(payload, cfg) {
const action = payload.action;
if (!["opened", "synchronize", "reopened", "ready_for_review"].includes(action)) {
if (!PR_ACTIONS.has(action)) {
return { queued: 0, reason: `action ${action} ignored` };
}
const owner = payload.repository?.owner?.username || payload.repository?.owner?.login;