Skip to content

Commit 1b8f629

Browse files
author
Kit (OpenClaw)
committed
Add script/gh_auth_check to verify gh CLI installation and auth
Exits non-zero with actionable guidance if gh is not installed or not authenticated. Closes #926.
1 parent 9d64b7d commit 1b8f629

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

script/gh_auth_check

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# script/gh_auth_check
3+
# Verifies that the GitHub CLI (gh) is installed and authenticated.
4+
# Exits non-zero with actionable guidance if either check fails.
5+
6+
set -euo pipefail
7+
8+
# ── 1. Check gh is installed ──────────────────────────────────────────────────
9+
if ! command -v gh &>/dev/null; then
10+
echo "ERROR: gh CLI is not installed." >&2
11+
echo "" >&2
12+
echo "Install it with one of the following:" >&2
13+
echo " macOS: brew install gh" >&2
14+
echo " Linux: https://github.com/cli/cli/blob/trunk/docs/install_linux.md" >&2
15+
echo " Windows: https://github.com/cli/cli#windows" >&2
16+
exit 1
17+
fi
18+
19+
# ── 2. Check gh is authenticated ─────────────────────────────────────────────
20+
if ! gh auth status &>/dev/null; then
21+
echo "ERROR: gh CLI is not authenticated." >&2
22+
echo "" >&2
23+
echo "Run the following to log in:" >&2
24+
echo " gh auth login" >&2
25+
echo "" >&2
26+
echo "Then re-run this check:" >&2
27+
echo " ./script/gh_auth_check" >&2
28+
exit 1
29+
fi
30+
31+
echo "gh CLI is installed and authenticated."

0 commit comments

Comments
 (0)