After a push it’s tempting to keep a browser tab open on the Actions page and refresh it. gh run watch follows the run in the terminal instead.
Run it inside the repository. Without a run ID it lets you pick one of the runs in progress, then shows each job and step as it moves along:
gh run watch --exit-status
--exit-status is the part that makes it useful in scripts. Normally the command exits 0 when the run ends, whatever the result. With the flag it exits non-zero when the run failed, so you can chain the next step:
id=$(gh run list --limit 1 --json databaseId --jq '.[0].databaseId')
gh run watch "$id" --exit-status --compact && ./deploy.sh
--compact shows only the relevant or failed steps, which keeps the screen calm for workflows with many steps. -i changes the refresh interval from the default of 3 seconds.
I like ending it with a notification command, so you can look at something else and still hear when the build is done.
The help notes that it does not work with fine grained personal access tokens, because those can’t get the checks permission it needs. A classic token or the normal gh auth login works. Picking the latest run with gh run list can also grab a run from another branch or workflow, so add --branch or --workflow when the repository is busy.
Further reading: gh run watch (GitHub CLI manual), gh run list (GitHub CLI manual)
Going deeper: Moving on from hdtv: how to export your TV show list to Trakt.tv