fix(Step9): 優先用 Gitea 狀態阻擋合併
AI / 計算版本號 (pull_request) Successful in 2s
AI / Code Review (pull_request) Successful in 1m39s

This commit is contained in:
2026-06-22 10:32:58 +00:00
parent 75cbfd38b0
commit bd89eb573f
4 changed files with 55 additions and 4 deletions
+17
View File
@@ -118,6 +118,23 @@ export async function postComment(body) {
return resp.data;
}
export async function blockPRMergeWithStatus({ sha = PR_HEAD_SHA || process.env.GITHUB_SHA, criticalCount = 0 } = {}) {
if (!sha) throw new Error('缺少 PR head commit sha,無法建立 Gitea status');
const countText = criticalCount > 0 ? `${criticalCount}` : '';
const resp = await axios.post(
api(`/repos/${GITEA_REPOSITORY}/statuses/${encodeURIComponent(sha)}`),
{
state: 'failure',
target_url: `${GITEA_SERVER_URL.replace(/\/$/, '')}/${GITEA_REPOSITORY}/pulls/${PR_NUMBER}`,
description: `AI Code Review 發現${countText}嚴重問題,請修復後再合併。`,
context: 'ai-code-review/critical',
},
{ headers: headers(), timeout: 30000, httpsAgent },
);
return resp.data;
}
/**
* 在 PR 指定檔案的指定行數發布行內 review comment(標註程式碼位置)。
* 透過 Gitea 的 pull reviews API,以 new_position 對應新版檔案的行號。