Files
2025-11-30 09:08:16 +08:00

24 lines
776 B
Bash
Executable File

#!/usr/bin/env bash
# Get CI check status for a PR
# Usage: gh-pr-checks <PR_NUMBER> [REPO]
set -euo pipefail
PR_NUMBER="${1:?Usage: gh-pr-checks <PR_NUMBER> [REPO]}"
REPO="${2:-}"
if [[ -z "$REPO" ]]; then
REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner' 2>/dev/null || true)
if [[ -z "$REPO" ]]; then
echo "Error: Could not detect repo. Provide REPO as second argument" >&2
exit 1
fi
fi
# Get the head SHA first
HEAD_SHA=$(gh api "repos/${REPO}/pulls/${PR_NUMBER}" --jq '.head.sha')
gh api "repos/${REPO}/commits/${HEAD_SHA}/check-runs" | jq -r '
.check_runs[] |
"\(if .conclusion == "success" then "✓" elif .conclusion == "failure" then "✗" elif .status == "in_progress" then "⋯" else "?" end) \(.name): \(.conclusion // .status)"'