Bright Labs

How to view only failed step logs for GitHub Actions PR checks

Long GitHub Actions logs bury a single failing step under setup output and passing steps. Run gh pr checks to check CI status for the pull request, then run gh run view --job JOB_ID --log-failed to filter logs to failed steps.

If you prefer the web UI, open the workflow run summary from the list of workflow runs. GitHub automatically expands any failed steps to display the results. One catch is easy to miss: you must be logged in to a GitHub account to view workflow run information, including for public repositories.

Check pull request status from the terminal with gh pr checks

Run gh pr checks to show CI status for a single pull request. Without an argument, it selects the pull request that belongs to the current branch. You can also pass a pull request number, URL, or branch name.

If a pull request triggers multiple checks, pass --required to only show checks that are required. To open the web browser and show details about checks, pass --web.

When checks are still running, --watch watches checks until they finish. Add --fail-fast to exit watch mode on the first check failure so you don't wait on the rest.

You can pass --json to output JSON with the specified fields. To select another repository, pass --repo using the [HOST/]OWNER/REPO format. Once you see which check failed, grab its run or job ID and pull the logs.

To filter logs to failed steps, pass --log-failed to gh run view with --job JOB_ID.

Print only failed step logs for a job
gh run view --job JOB_ID --log-failed

If you don't have a run ID handy, omit it when you run gh run view. GitHub CLI returns an interactive menu for you to choose a recent run, and then returns another interactive menu for you to choose a job from the run. If you already know the run ID, run gh run view RUN_ID --log to view logs for that run.

When you need to search across a full job log instead, pass --log with --job JOB_ID and pipe it to grep. You can use grep to search the log for errors.

Search a full job log with grep
gh run view --job JOB_ID --log | grep error

To see job steps for a run, pass --verbose to gh run view RUN_ID. If you're checking a run in a script, use the --exit-status flag to exit with a non-zero status if the run failed.

Exit non-zero if a workflow run failed
gh run view 0451 --exit-status && echo "run pending or passed"

Read failed steps and search logs in the web UI

In the web UI, click the name of the run from the list of workflow runs to see the workflow run summary. Read access to the repository is required to view, search, and download logs.

Any failed steps are automatically expanded to display the results. You can also see the time it took for each step to run.

In addition to the steps configured in the workflow file, GitHub adds two additional steps to each job to set up and complete the job's execution. These steps are logged with the names Set up job and Complete job. On GitHub-hosted runners, Set up job records details of the runner image and includes a link to the list of preinstalled tools present on the runner machine.

When you need a link to a specific line in the logs, click on the step's line number. You can then copy the link from the address bar of your web browser.

If you search logs in the web UI, keep this catch in mind: when you search logs, only expanded steps are included in the results. If the text you want sits in a collapsed step, expand that step first.

When you download the log archive for a workflow that was partially re-run, the archive only includes the jobs that were re-run. To get a complete set of logs for jobs that were run from a workflow, select a previous run attempt from the Latest dropdown menu to the right of the run name. From there, download the log archives for the previous run attempts that ran the other jobs.

Check recent workflow history before you re-run

Before you hit re-run on a red job, check recent workflow runs to see if that failure keeps showing up. Run gh run list to list recent workflow runs, and combine flags to narrow the list:

Limit recent workflow runs returned by gh run list
gh run list --limit 5

Two gh run list catches are easy to miss. Providing workflow_name to the -w flag will not fetch disabled workflows on its own, so also pass the -a flag to fetch disabled workflow runs. Also, runs created by organization and enterprise ruleset workflows will not display a workflow name due to GitHub API limitations.

If you pull run history from a script instead of the CLI, the REST API lists all workflow runs for a repository and accepts parameters to narrow the results. Anyone with read access to the repository can use this endpoint. You can filter with the branch parameter and request up to 100 results per page with per_page.

If you want that check history directly on the GitHub pull request page without querying runs yourself, FlakeRadar is a Chrome extension we built for GitHub Actions users. It reads the repository's own GitHub Actions history and labels each failing job as Known flake, New failure, Also failing on the default branch, or Not enough history, while checks from other CI systems are not analysed.

Each label comes with counts, a time window, and a date, such as failed then passed on the same commit on 4 of 120 commits on main in the last 30 days. FlakeRadar runs in your browser and reads api.github.com with a fine-grained personal access token that you create and keep on your device, with no CI config changes, no secrets, no report uploads, no analytics, and no telemetry.

The Free plan is $0 and includes labels for failing checks on public repositories, 30 days of history, and one-click re-run if you turn it on. The Pro plan is $19/month and includes everything in Free, private repositories, 90 days of history, pinned repositories, a refresh button, and alerts. Known flake is historical evidence rather than a promise that a failure is safe to ignore, so read the log when a failure matters.

Re-run only failed jobs once you check the log

Once you confirm the failure looks transient, re-run only the failed jobs instead of the whole workflow. Pass --failed to gh run rerun with RUN_ID to re-run failed jobs in a workflow run. To re-run a single job, pass --job JOB_ID.

Re-run only failed jobs in a workflow run
gh run rerun RUN_ID --failed

People with write permissions to a repository can re-run a workflow run, all failed jobs in a workflow run, or specific jobs in a workflow run up to 30 days after its initial run.

Keep two limits in mind before triggering retries. A workflow run can be re-run a maximum of 50 times. You also can't re-run a workflow run, or any of its jobs, while the workflow is disabled.

When you re-run failed jobs or a specific job, GitHub also re-runs the jobs that depend on them. Jobs that aren't included keep their outputs from the previous attempt, which the newly run jobs can use. Re-runs use the privileges of the actor who initially triggered the workflow, not the privileges of the actor who initiated the re-run. The workflow also uses the same GITHUB_SHA and GITHUB_REF of the original event that triggered the workflow run.

Sources

Questions

Why doesn't searching logs find text that I know is in my workflow run?

When you search logs in the web UI, only expanded steps are included in the results. Any failed steps expand automatically, so if the text is inside a collapsed step, expand that step before searching.

Why does the log archive miss some jobs after I re-run a failed job?

When you download the log archive for a workflow that was partially re-run, the archive only includes the jobs that were re-run. To get a complete set of logs for jobs that were run from a workflow, select a previous run attempt from the Latest dropdown menu to the right of the run name and download the log archives for the previous run attempts that ran the other jobs.

Why doesn't gh run list -w show runs from a disabled workflow?

Providing a workflow_name to the -w flag in gh run list does not fetch disabled workflows on its own. Pass the -a flag along with -w to fetch disabled workflow runs.

Can I view GitHub Actions workflow run logs on a public repository without signing in?

No. You must be logged in to a GitHub account to view workflow run information, including for public repositories.

Related