PRCheckloop
Get a GitHub PR to a fully green check state, or exit with a concrete blocker.
Scope
- GitHub PRs only. If the repo is GitLab, stop and use
check-pr. - Focus on checks for the latest PR head SHA, not old commits.
- Focus on CI/status checks, not review comments or PR template cleanup.
- If the user also wants review-comment cleanup, pair this with
check-pr.
Inputs
- PR number (optional): If not provided, detect the PR for the current branch.
- Max iterations: default
5.
Workflow
1. Identify the PR
If no PR number is provided, detect it from the current branch:
gh pr view --json number,headRefName,headRefOid,url,isDraft
If needed, switch to the PR branch before making changes.
Stop early if:
ghis not authenticated- there is no PR for the branch
- the repo is not hosted on GitHub
2. Track the latest head SHA
Always work against the current PR head SHA:
PR_JSON=$(gh pr view "$PR_NUMBER" --json number,headRefName,headRefOid,url)
HEAD_SHA=$(echo "$PR_JSON" | jq -r .headRefOid)
PR_URL=$(echo "$PR_JSON" | jq -r .url)
Ignore failing checks from older SHAs. After every push, refresh HEAD_SHA and
res…