brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: gh run view --log-failed prints only the log of the steps that failed

CLI
~/tips/tip-github-run-view-log-failed

gh run view 12345 --log-failed

Shows the log of failed workflow steps in your terminal, without opening the whole run.

A red cross on a workflow run means clicking through to the run, then the job, then expanding the right step in a web page that loads a few thousand lines. For the usual question, which step broke and why, there is a shorter route from the terminal.

gh run view 12345 --log-failed

The help text says --log-failed views the log for any failed steps in a run or a specific job. Leave out the run id and gh lets you pick a run interactively. A few related flags from the same page:

  • --log prints the full log of a run or a job.
  • -j, --job limits the view to one job id.
  • -a, --attempt picks an attempt number of the run.
  • --exit-status exits with a non-zero status if the run failed.

The last one is useful in a script, and the manual has this example:

gh run view 0451 --exit-status && echo "run pending or passed"

Note the wording of that echo: a run that is still pending also counts as not failed.

Caveats from the help text. Because of platform limitations, gh may not always be able to match jobs with their logs when it fetches them as a zip. It then tries to fetch the log of each job separately, which is slower, and if more than 25 job logs are missing, the operation fails with an error. Some log lines may also not belong to a specific step, and then the step shows up as UNKNOWN STEP.

You need gh auth login first. This was not run against a live repository; it follows the help text and the manual.

Further reading: gh run view manual

Going deeper: Moving on from hdtv: how to export your TV show list to Trakt.tv

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso wget --spider https://example.com/file.zip rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' All CLI tips (46) All topics

Link