Initial commit
This commit is contained in:
23
skills/github-pr-workflow/scripts/gh-pr-checks
Executable file
23
skills/github-pr-workflow/scripts/gh-pr-checks
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/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)"'
|
||||
Reference in New Issue
Block a user