From d29a6565f915f1afc8749a617d2f1d2c604407ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 06:26:53 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=AE=A1=E6=9F=A5=E5=8F=8D=E9=A6=88=20-=20URL=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E3=80=81=E6=A0=87=E7=AD=BE=E5=8C=B9=E9=85=8D=E3=80=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 GitHub API 日期过滤的 URL 编码 - 移除未使用的 getJobLog 函数 - 改进 pending 标签移除的错误处理 - 修复工作流中标签匹配逻辑 Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- .github/workflows/bingshuo-deploy-agent.yml | 2 +- scripts/bingshuo-deploy-agent.js | 22 +++++++-------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/bingshuo-deploy-agent.yml b/.github/workflows/bingshuo-deploy-agent.yml index c4eb6587..1b212866 100644 --- a/.github/workflows/bingshuo-deploy-agent.yml +++ b/.github/workflows/bingshuo-deploy-agent.yml @@ -48,7 +48,7 @@ jobs: contains(github.event.comment.body, '部署诊断') || contains(github.event.comment.body, '检查部署') )) || - (github.event_name == 'issues' && contains(toJSON(github.event.issue.labels), 'bingshuo-deploy')) + (github.event_name == 'issues' && contains(join(github.event.issue.labels.*.name, ','), 'bingshuo-deploy')) steps: - name: 📥 检出代码 diff --git a/scripts/bingshuo-deploy-agent.js b/scripts/bingshuo-deploy-agent.js index 0a5d471d..ac45e70a 100644 --- a/scripts/bingshuo-deploy-agent.js +++ b/scripts/bingshuo-deploy-agent.js @@ -92,7 +92,7 @@ function githubAPI(method, path, data) { async function getRecentRuns() { const since = new Date(Date.now() - HOURS_BACK * 60 * 60 * 1000).toISOString(); const result = await githubAPI('GET', - `/repos/${OWNER}/${REPO_NAME}/actions/runs?per_page=100&created=>${since}` + `/repos/${OWNER}/${REPO_NAME}/actions/runs?per_page=100&created=%3E${since}` ); if (result.status !== 200) { console.error('❌ 获取工作流运行记录失败:', result.status); @@ -110,17 +110,6 @@ async function getJobsForRun(runId) { return result.data.jobs || []; } -// === 获取某个作业的日志(最后200行)=== -async function getJobLog(jobId) { - // GitHub API 返回日志的重定向URL - const result = await githubAPI('GET', - `/repos/${OWNER}/${REPO_NAME}/actions/jobs/${jobId}/logs` - ); - // 日志接口返回 302 重定向,但我们的简单 HTTPS 客户端无法跟随 - // 改用 jobs 接口获取步骤信息作为替代 - return null; -} - // === 从 jobs 中提取失败信息 === function extractFailureInfo(jobs) { const failures = []; @@ -392,10 +381,13 @@ async function postReport(report) { `/repos/${OWNER}/${REPO_NAME}/issues/${ISSUE_NUMBER}/labels`, { labels: ['🧊deploy-report', '✅answered'] } ); - // 移除 pending 标签 - await githubAPI('DELETE', + // 移除 pending 标签(如果不存在会返回404,属正常情况) + const removeResult = await githubAPI('DELETE', `/repos/${OWNER}/${REPO_NAME}/issues/${ISSUE_NUMBER}/labels/${encodeURIComponent('pending')}` - ).catch(() => null); + ); + if (removeResult.status !== 200 && removeResult.status !== 404) { + console.warn('⚠️ 移除 pending 标签时出现异常:', removeResult.status); + } console.log(`✅ 报告已发布到 Issue #${ISSUE_NUMBER}`); } else {