babysit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBabysit a PR
值守PR
Check mergeability first, then run one watcher and wait for its process
to finish. Success means the intended checks completed for the current PR
head, with any failures or missing checks accounted for. Babysitting does not
authorize merging, bypassing gates, or posting review comments.
gh首先检查可合并性,然后运行一个监听器并等待其进程结束。成功意味着当前PR head的所有预期检查均已完成,所有失败或缺失的检查都已得到说明。值守PR并不授权合并、绕过门禁或发布审查评论。
ghCheck for conflicts before waiting
等待前先检查冲突
Use an explicit PR number and repository throughout:
sh
gh pr view <n> -R <owner/repo> --json state,url,headRefOid,baseRefName,baseRefOid,mergeable,mergeStateStatus,isDraft,reviewDecisionRecord the head SHA, base branch, and base SHA. Stop watching if the PR is closed or
merged. Handle before starting a watcher:
mergeable- : use resolve-pr-conflicts against this PR's current base, then repeat this inspection after pushing.
CONFLICTING - : GitHub has not established mergeability. Recheck after a short delay; if still unknown, inspect a fetched head/base locally or report the unresolved state. Do not assume it is conflict-free or loop indefinitely.
UNKNOWN - : proceed. Other merge gates can still block the PR;
MERGEABLEalone does not establish a textual conflict.mergeStateStatus: BLOCKED
GitHub does not run workflows triggered by while merge
conflicts exist. Resolving conflicts first prevents waiting for checks that
cannot start. See GitHub's workflow troubleshooting.
pull_request全程使用明确的PR编号和仓库:
sh
gh pr view <n> -R <owner/repo> --json state,url,headRefOid,baseRefName,baseRefOid,mergeable,mergeStateStatus,isDraft,reviewDecision记录head SHA、base分支和base SHA。如果PR已关闭或已合并,停止监听。启动监听器前先处理状态:
mergeable- :针对该PR的当前base分支使用resolve-pr-conflicts,推送后重复本次检查。
CONFLICTING - :GitHub尚未确定可合并性。稍等片刻后重新检查;如果仍为未知状态,在本地检查拉取的head/base分支,或报告未解决的状态。不要假设其无冲突,也不要无限循环检查。
UNKNOWN - :继续操作。其他合并门禁仍可能阻止PR;仅
MERGEABLE并不代表存在文本冲突。mergeStateStatus: BLOCKED
存在合并冲突时,GitHub不会运行由触发的工作流。先解决冲突可以避免等待根本无法启动的检查。参见GitHub工作流故障排查。
pull_requestLet gh watch the checks
用gh监听检查状态
sh
gh pr checks <n> -R <owner/repo> --watch --interval 10The PR checks command refreshes
every ten seconds by default and waits until the reported checks finish.
Use when a failure should return control immediately for repair.
Add only when the task concerns required checks alone; it can
exclude a review bot's optional check.
--fail-fast--requiredRun the command once as a long-running process. Use the execution tool's
completion notification or wait on the same session with long practical
waits. Do not alternate fresh calls with model-driven sleeps,
restart the watcher on each tool yield, or narrate unchanged refreshes.
gh pr checksThis is CLI-managed polling, not a server event subscription. The
implementation
refreshes while checks are pending and exits when none remain. It does not
stay subscribed for checks created later or for future review comments.
Inspect the final output and exit status. Failed checks return nonzero;
ordinary non-watch output uses exit code 8 for pending checks. Authentication,
API, and missing-check errors also need diagnosis. Use a separate snapshot
when structured details help:
sh
gh pr checks <n> -R <owner/repo> --json name,bucket,state,workflow,linkDo not combine with . JSON is a snapshot, and its successful
export does not prove checks passed. Inspect values; cancelled or
skipped checks are not evidence that the intended tests ran.
--json--watchbucketsh
gh pr checks <n> -R <owner/repo> --watch --interval 10PR checks命令默认每十秒刷新一次,会一直等待直到所有上报的检查完成。当出现失败时需要立即返回进行修复时,使用参数。仅当任务仅涉及必需检查时才添加参数;该参数会排除审查机器人的可选检查。
--fail-fast--required将该命令作为长期运行的进程执行一次。使用执行工具的完成通知,或在同一会话中进行合理的长时间等待。不要交替执行新的调用和模型驱动的休眠,不要在每次工具返回时重启监听器,也不要重复播报无变化的刷新结果。
gh pr checks这是CLI管理的轮询机制,而非服务器事件订阅。该实现会在检查待处理时持续刷新,当没有待处理检查时退出。它不会持续订阅后续创建的检查或未来的审查评论。
检查最终输出和退出状态。检查失败时返回非零值;普通非监听模式下,待处理检查的退出码为8。身份验证、API和检查缺失类错误也需要诊断。当需要结构化详情时,使用单独的快照命令:
sh
gh pr checks <n> -R <owner/repo> --json name,bucket,state,workflow,link不要将与参数组合使用。JSON是快照,其成功导出并不代表检查已通过。检查值;已取消或已跳过的检查不能证明预期测试已运行。
--json--watchbucketHandle checks that cannot finish
处理无法完成的检查
If no checks are reported, the watcher exits with an error rather than waiting
for their creation. If an expected check is missing, or a pending check has no
progress beyond its normal runtime, inspect the workflow and run details.
Check for conflicts again, trigger/path filters, skip annotations, workflow
approval, and unavailable runners as the evidence warrants. Do not repeatedly
restart a watcher for a workflow that cannot run. Resume once the blocker is
resolved; otherwise report the blocker.
For a known GitHub Actions run, use its specific ID:
sh
gh run watch <run-id> -R <owner/repo> --exit-status --compact --interval 10
gh run view <run-id> -R <owner/repo> --log-failedThe run watcher covers one Actions
run, not every PR check. makes run failure return nonzero.
It does not support fine-grained PAT authentication. Inspect failure logs when
needed; repair and push within the authorized task, then start with the
conflict check again. Do not rerun failures repeatedly without a diagnosis.
--exit-statusA review service that publishes a check can be watched through .
A service that only posts comments or reviews is outside these watchers.
Use that service's completion mechanism if available; otherwise report that
limitation rather than treating green CI as a completed review.
gh pr checks如果没有上报任何检查,监听器会报错退出,而不会等待检查被创建。如果缺失预期的检查,或某个待处理检查超出正常运行时间仍无进展,请检查工作流和运行详情。根据实际情况排查冲突、触发器/路径过滤器、跳过注解、工作流审批以及运行器不可用等问题。不要为无法运行的工作流反复重启监听器。解决阻塞问题后再继续;否则请上报阻塞问题。
对于已知的GitHub Actions运行记录,使用其特定ID:
sh
gh run watch <run-id> -R <owner/repo> --exit-status --compact --interval 10
gh run view <run-id> -R <owner/repo> --log-failedrun监听器仅覆盖单个Actions运行,而非所有PR检查。参数会让运行失败时返回非零值。它不支持细粒度PAT身份验证。必要时检查失败日志;在授权任务范围内修复并推送代码,然后从冲突检查开始重新执行。不要在未诊断的情况下反复重跑失败的任务。
--exit-status发布检查结果的审查服务可以通过监听。仅发布评论或审查意见的服务不在这些监听器的覆盖范围内。如果有可用的完成机制,请使用该服务的机制;否则请说明该限制,不要将CI通过等同于审查完成。
gh pr checksVerify the result
验证结果
Re-read the PR state, head SHA, base branch and SHA, and mergeability after the watcher
exits. Take a final checks snapshot and confirm the expected checks appeared.
If the head or base changed, or conflicts appeared, repeat the preflight and
watch the current checks before claiming success. A watcher exit alone does
not prove merge readiness or review approval.
Report the PR, verified head SHA, check results, and any review or workflow
blocker. Continue to merging only when the user's task authorizes it.
监听器退出后,重新读取PR状态、head SHA、base分支与SHA以及可合并性。获取最终的检查快照,确认预期的检查均已出现。如果head或base发生变化,或出现冲突,请重复预检步骤并监听当前检查,之后再确认成功。仅监听器退出并不能证明PR已准备好合并或已通过审查。
上报PR、已验证的head SHA、检查结果以及任何审查或工作流阻塞问题。仅当用户任务授权时,才可继续进行合并操作。