GitHub CLI operations
v0.1.17GitHub introspection — PRs, issues, repos, workflow runs, releases, commit checks, search — plus operator actions: merge PR, close PR, rerun workflow, dispatch workflow. Authenticates via the runner host's `gh auth status` token (i.e. ~/.config/gh).
gh
jq
Install
emisar pack install
fetches this pack, re-validates it, and verifies its content hash against the
--hash
below before copying it into the runner's packs dir. That hash covers the exact bytes
this page was built from, so a tampered copy is rejected. The command reloads a
running daemon itself, so you don't need to restart it manually.
sudo emisar pack install github-cli --hash sha256:1feccd82fd6e656434c8d4d4888ed5a0147aee16ceca0205b43e5d2542037a79
Setup
Actions use
gh
on the runner host; PR check projections also need
jq
. gh authenticates with
GH_TOKEN
(or
GITHUB_TOKEN
) if set, otherwise with the token stored by
gh auth login
. Provide one of those so gh is signed in.
Environment
Set these on the runner host, then add each name to
execution.inherit_env
so the value reaches the action.
-
GH_TOKENCreate a token in GitHub Settings → Developer settings → Personal access tokens. Omit if the runner user is already signed in via
gh auth login.
Notes
- Create a fine-grained token for the selected repositories. Grant read-only Contents, Pull requests, Issues, Actions, and Commit statuses for the corresponding reads. Organization approval may be required.
- PR checks first use the check contexts visible to the credential. When GitHub denies those contexts, the result falls back to Actions runs/jobs and commit statuses for the captured head commit. Non-Actions check runs are explicitly not visible in that fallback; it is not an all-checks or mergeability verdict. GitHub's fine-grained PAT Checks support varies by endpoint and is still listed as a limitation in its PAT guide.
-
Classic tokens
need
repofor private repositories; that scope is not read-only.gh auth loginstores a credential in the runner user's~/.config/gh/hosts.yml, rather than making the connection token-free. -
Merging/closing PRs requires Pull requests write; rerunning/dispatching workflows requires Actions write (dispatch also needs Contents read). Traffic (
repo_clone_count) requires repository write access and Administration read for a fine-grained token, orrepofor a classic token.
Verify it works
Runs gh.auth_status, a low-risk
read that confirms the pack can reach its target. Run it on the host once the pack
is installed; pack install runs it for
you.
sudo emisar pack verify github-cli
Install and configure a pack walks through the whole sequence on a host.
Actions 19 total
View on GitHub-
gh.auth_status exec low Low: read-only or trivially reversible
gh auth status
Show which GitHub account the runner's `gh` is signed in as + token scopes.
View source on GitHub -
gh.branch_list exec low Low: read-only or trivially reversible
gh api repos/<repo>/branches
List branches in the repo (paginated, up to 100).
View source on GitHub -
gh.issue_list exec low Low: read-only or trivially reversible
gh issue list
List open issues for one repo.
View source on GitHub -
gh.issue_view exec medium Medium: changes state, easily reversible
gh issue view
Show one issue's details, body and comments, including arbitrary application text that may contain sensitive data.
View source on GitHub -
gh.pr_checks script low Low: read-only or trivially reversible
gh pr checks
List visible checks for a captured PR head commit as JSON; failed or pending checks are data, not a failed query. If GitHub denies check contexts, return commit statuses and up to 10 Actions runs with the first 100 jobs of each observed attempt. Each REST collection is one page of up to 100; omitted rows and unavailable non-Actions checks are explicit. This is a bounded observation, not proof of branch-protection satisfaction or mergeability.
View source on GitHub -
gh.pr_close exec medium Medium: changes state, easily reversible
gh pr close <num>
Close one PR without merging. Use for stale or abandoned PRs. Reopenable via the UI or `gh pr reopen`.
View source on GitHub -
gh.pr_list exec low Low: read-only or trivially reversible
gh pr list
List open PRs for one repo.
View source on GitHub -
gh.pr_merge exec high High: can disrupt service
gh pr merge <num> --<method>
Merge an open PR. Squash, merge-commit, or rebase. Branch protection rules still apply — required checks/approvals must be satisfied or the merge is rejected. Use --auto in the GH UI for "merge when ready" instead; this action commits NOW.
View source on GitHub -
gh.pr_view script medium Medium: changes state, easily reversible
gh pr view
Show one PR's title, body, state, review decision and visible head-commit checks. The body is arbitrary application text and may contain sensitive data. Checks use the same bounded, explicitly partial fallback as gh.pr_checks when the credential cannot read check contexts; this is not an all-checks or mergeability verdict. An oversized JSON result fails rather than returning a truncated document.
View source on GitHub -
gh.release_list exec low Low: read-only or trivially reversible
gh release list
List recent releases.
View source on GitHub -
gh.repo_clone_count exec low Low: read-only or trivially reversible
gh api repos/<repo>/traffic/clones
Show last-14-day clone counts (requires push access on the repo).
View source on GitHub -
gh.repo_view exec low Low: read-only or trivially reversible
gh repo view
Show repo summary — description, stars, default branch, latest release.
View source on GitHub -
gh.search_prs script low Low: read-only or trivially reversible
gh search prs
Search PRs across GitHub with separate query terms and a caller limit of up to 100 results per bounded response.
View source on GitHub -
gh.workflow_dispatch exec high High: can disrupt service
gh workflow run <workflow>
Trigger a workflow that supports workflow_dispatch. Pass ref + JSON inputs. Used for ad-hoc deploys, scripted rollbacks, or manual release flows.
View source on GitHub -
gh.workflow_list exec low Low: read-only or trivially reversible
gh workflow list
List all workflows defined in one repo.
View source on GitHub -
gh.workflow_rerun exec medium Medium: changes state, easily reversible
gh run rerun <run-id>
Re-run one workflow run. Useful after fixing a transient infrastructure issue. With --failed, only re-runs failed jobs.
View source on GitHub -
gh.workflow_run_list exec low Low: read-only or trivially reversible
gh run list
List recent workflow runs across the repo.
View source on GitHub -
gh.workflow_run_logs exec medium Medium: changes state, easily reversible
gh run view --log-failed
Show logs from failed jobs in one run. Use for "why did CI break?".
View source on GitHub -
gh.workflow_run_view exec low Low: read-only or trivially reversible
gh run view
Show job-by-job result for one workflow run.
View source on GitHub