LinuxCommandLibrary

gh-run

View, list, and manage GitHub Actions runs

TLDR

Interactively select a run to see information about the jobs

$ gh run view
copy

Display information about a specific run
$ gh run view [workflow_run_number]
copy

Display information about the steps of a job
$ gh run view [[-j|--job]] [job_number]
copy

Display the log of a job
$ gh run view [[-j|--job]] [job_number] --log
copy

Check a specific workflow and exit with a non-zero status if the run failed
$ gh run view [workflow_run_number] --exit-status && [echo "run pending or passed"]
copy

Interactively select an active run and wait until it's done
$ gh run watch
copy

Display the jobs for a run and wait until it's done
$ gh run watch [workflow_run_number]
copy

Re-run a specific workflow
$ gh run rerun [workflow_run_number]
copy

SYNOPSIS

gh run <list|view|download|watch|cancel|approve|rerun> [<run-id>] [options]

PARAMETERS

--branch <branch>
    Filter by branch name or ref

--limit <number>
    Maximum number of runs to list (default 20)

--repo <OWNER/REPO>
    Repository to interact with

--status <status>
    Filter by status: queued, in_progress, success, failure

--workflow <query>
    Filter by workflow ID, filename, or name

--name <artifact-name>
    Download specific artifact (for download)

--jq <expression>
    Query JSON output using JMESPath

--json <fields>
    Output JSON fields only

DESCRIPTION

The gh run command is part of the GitHub CLI (gh) for interacting with GitHub Actions workflow runs from the terminal. It enables listing recent runs, viewing details, downloading artifacts, watching progress, canceling jobs, approving workflows, and rerunning failures.

Use it to debug CI/CD pipelines, automate monitoring, or integrate Actions into scripts. Filter by branch, status (queued, in_progress, success, failure), or workflow ID/file. Specify repo with --repo if outside a Git repo.

Key subcommands: list shows runs with optional limits/filters; view displays logs/jobs; download fetches artifacts; watch tails live output; cancel/rerun controls execution. Outputs JSON via --jq for scripting. Requires gh auth login for access.

CAVEATS

Requires GitHub CLI authentication via gh auth login. Limited to repos with read access. Interactive prompts (watch, view) fail in non-TTY. Enterprise Server support varies by version.

COMMON EXAMPLES

gh run list --branch main --status failure
gh run view 123456
gh run download 123456 --name my-artifact
gh run watch 123456

SUBCOMMANDS

list: List runs.
view <id>: Show details/logs.
download <id>: Fetch artifacts.
watch <id>: Tail progress.
cancel <id>: Stop run.
rerun <id>: Retry failures.

HISTORY

Introduced in GitHub CLI v0.5.0 (Feb 2020) with basic list/view. Expanded in v1.x+ (2021+) to include download, watch, cancel, rerun, and artifact/job management. Tracks GitHub Actions API evolution.

SEE ALSO

gh(1), gh-workflow(1), git(1)

Copied to clipboard