openai-gh-fix-ci
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGh Pr Checks Plan Fix
Gh PR 检查修复方案与实施流程
Overview
概述
Use gh to locate failing PR checks, fetch GitHub Actions logs for actionable failures, summarize the failure snippet, then propose a fix plan and implement after explicit approval.
- If a plan-oriented skill (for example ) is available, use it; otherwise draft a concise plan inline and request approval before implementing.
create-plan
Prereq: authenticate with the standard GitHub CLI once (for example, run ), then confirm with (repo + workflow scopes are typically required).
gh auth logingh auth status使用gh工具定位失败的PR检查任务,获取GitHub Actions中可用于排查的失败日志,总结失败片段,然后提出修复方案,且仅在获得明确批准后再实施。
- 如果有面向方案制定的技能(例如),请使用该技能;否则直接起草一份简洁的方案,并在实施前请求批准。
create-plan
前置条件:先通过标准GitHub CLI完成身份验证(例如,运行),然后使用确认验证状态(通常需要repo和workflow权限范围)。
gh auth logingh auth statusInputs
输入参数
- : path inside the repo (default
repo). - : PR number or URL (optional; defaults to current branch PR)
pr - authentication for the repo host
gh
- : 仓库内的路径(默认值为
repo). - : PR编号或URL(可选;默认使用当前分支对应的PR)
pr - 针对仓库托管平台的gh身份验证
Quick start
快速开始
python "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --pr "<number-or-url>"- Add if you want machine-friendly output for summarization.
--json
python "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --pr "<编号或URL>"- 如果需要便于机器处理的输出用于总结,请添加参数。
--json
Workflow
执行流程
- Verify gh authentication.
- Run in the repo.
gh auth status - If unauthenticated, ask the user to run (ensuring repo + workflow scopes) before proceeding.
gh auth login
- Run
- Resolve the PR.
- Prefer the current branch PR: .
gh pr view --json number,url - If the user provides a PR number or URL, use that directly.
- Prefer the current branch PR:
- Inspect failing checks (GitHub Actions only).
- Preferred: run the bundled script (handles gh field drift and job-log fallbacks):
python "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --pr "<number-or-url>"- Add for machine-friendly output.
--json
- Manual fallback:
gh pr checks <pr> --json name,state,bucket,link,startedAt,completedAt,workflow- If a field is rejected, rerun with the available fields reported by .
gh
- If a field is rejected, rerun with the available fields reported by
- For each failing check, extract the run id from and run:
detailsUrlgh run view <run_id> --json name,workflowName,conclusion,status,url,event,headBranch,headShagh run view <run_id> --log
- If the run log says it is still in progress, fetch job logs directly:
gh api "/repos/<owner>/<repo>/actions/jobs/<job_id>/logs" > "<path>"
- Preferred: run the bundled script (handles gh field drift and job-log fallbacks):
- Scope non-GitHub Actions checks.
- If is not a GitHub Actions run, label it as external and only report the URL.
detailsUrl - Do not attempt Buildkite or other providers; keep the workflow lean.
- If
- Summarize failures for the user.
- Provide the failing check name, run URL (if any), and a concise log snippet.
- Call out missing logs explicitly.
- Create a plan.
- Use the skill to draft a concise plan and request approval.
create-plan
- Use the
- Implement after approval.
- Apply the approved plan, summarize diffs/tests, and ask about opening a PR.
- Recheck status.
- After changes, suggest re-running the relevant tests and to confirm.
gh pr checks
- After changes, suggest re-running the relevant tests and
- 验证gh身份验证状态。
- 在仓库中运行。
gh auth status - 如果未通过验证,请让用户先运行(确保获取repo和workflow权限范围),然后再继续。
gh auth login
- 在仓库中运行
- 确定目标PR。
- 优先使用当前分支对应的PR:运行。
gh pr view --json number,url - 如果用户提供了PR编号或URL,则直接使用该值。
- 优先使用当前分支对应的PR:运行
- 检查失败的任务(仅针对GitHub Actions)。
- 推荐方式:运行内置脚本(可处理gh字段变更和作业日志降级获取逻辑):
python "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --pr "<编号或URL>"- 添加参数以获取便于机器处理的输出。
--json
- 手动备选方案:
gh pr checks <pr> --json name,state,bucket,link,startedAt,completedAt,workflow- 如果某个字段不被支持,使用返回的可用字段重新运行命令。
gh
- 如果某个字段不被支持,使用
- 对于每个失败的任务,从中提取运行ID,然后运行:
detailsUrlgh run view <run_id> --json name,workflowName,conclusion,status,url,event,headBranch,headShagh run view <run_id> --log
- 如果运行日志显示任务仍在进行中,直接获取作业日志:
gh api "/repos/<owner>/<repo>/actions/jobs/<job_id>/logs" > "<路径>"
- 推荐方式:运行内置脚本(可处理gh字段变更和作业日志降级获取逻辑):
- 处理非GitHub Actions的检查任务。
- 如果指向的不是GitHub Actions运行任务,将其标记为外部任务,仅报告该URL。
detailsUrl - 不要尝试处理Buildkite或其他服务商的任务,保持流程简洁。
- 如果
- 为用户总结失败信息。
- 提供失败任务的名称、运行URL(如果有)以及简洁的日志片段。
- 明确指出缺失的日志信息。
- 制定修复方案。
- 使用技能起草一份简洁的方案,并请求批准。
create-plan
- 使用
- 获批后实施修复。
- 执行获批的方案,总结代码变更和测试情况,并询问是否需要提交PR。
- 重新检查状态。
- 完成变更后,建议重新运行相关测试,并执行确认修复效果。
gh pr checks
- 完成变更后,建议重新运行相关测试,并执行
Bundled Resources
内置资源
scripts/inspect_pr_checks.py
scripts/inspect_pr_checks.py
Fetch failing PR checks, pull GitHub Actions logs, and extract a failure snippet. Exits non-zero when failures remain so it can be used in automation.
Usage examples:
python "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --pr "123"python "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --pr "https://github.com/org/repo/pull/123" --jsonpython "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --max-lines 200 --context 40
获取失败的PR检查任务,拉取GitHub Actions日志,并提取失败片段。当存在失败任务时,脚本会以非零状态码退出,因此可用于自动化流程。
使用示例:
python "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --pr "123"python "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --pr "https://github.com/org/repo/pull/123" --jsonpython "{baseDir}/scripts/inspect_pr_checks.py" --repo "." --max-lines 200 --context 40
When to Use
适用场景
<!-- TODO: review -->
<!-- TODO: 审核 -->
When NOT to Use
不适用场景
<!-- TODO: review -->
<!-- TODO: 审核 -->