Sub topic 15
Troubleshooting failed or skipped runs
This chapter assumes you can read a workflow file, know what jobs and steps are, and have seen a run's log page. It covers how to tell why a run failed, and why a run did not start at all.
Start with the type of problem
A workflow problem falls into one of three groups. Each group points to a different place to look.
| Symptom | Likely group | Where to look |
|---|---|---|
| No run appears in the Actions tab | Trigger did not match | `on:` block, branch, file location |
| Run appears but shows a YAML error | Invalid workflow file | Error banner on the run page |
| Run starts and a step turns red | Test or setup failure | Step log, first error line |
Runs that never start
If nothing appears, check these in order:
- The file must sit in
.github/workflows/and end in.ymlor.yaml. - The workflow file must exist on the branch you pushed to. For
push, GitHub uses the file from the pushed commit. Forpull_request, it uses the merge result of the pull request. - The event must match. A workflow with
push: branches: [main]ignores pushes to a feature branch. Apaths:filter skips the run when no changed file matches. - Pull requests from forks, and pull requests with merge conflicts, do not run
pull_requestworkflows normally. Resolve the conflict and push again. - A commit message containing
[skip ci]skipspushandpull_requestruns.
Runs that fail
Open the failed run, click the red job, and expand the first red step. Read upward from the end of the output to the first real error. Later lines are often consequences of it.
Common causes:
- Dependency step fails.
npm cistops whenpackage-lock.jsonandpackage.jsondisagree. Runnpm installlocally and commit the updated lockfile. - Works locally, fails on the runner. Compare the Node.js version, the operating system, and environment variables. A test that depends on file name case passes on Windows and fails on
ubuntu-latest. - Missing secret. A secret that is not set expands to an empty string. Secrets are also not passed to workflows triggered by pull requests from forks.
- Service not ready. Integration tests that start before the database accepts connections fail at random. Add a health check to the service container.
- Matrix failure. With
fail-fast: true, the default, one failing combination cancels the others. Their jobs show as cancelled, not failed. Setfail-fast: falseto see every result.
Getting more detail
Re-run the job with debug logging. In the run page, choose Re-run jobs, then tick Enable debug logging. You can also set the repository secret or variable ACTIONS_STEP_DEBUG to true.
You can also add a step that prints the environment, which is safe as long as it does not print secrets:
- name: Show environment
if: ${{ failure() }}
run: |
node --version
npm --version
echo "Runner OS: $RUNNER_OS"
pwd
ls -laThe failure() condition makes this step run only after an earlier step has failed. For a step that must run even on failure but not on cancellation, use !cancelled(), as in the artifact upload from earlier chapters.
Exercise
A pull request changes only README.md. Your test workflow has paths: ['src/**'] under pull_request, and branch protection requires the "test" check. The pull request cannot be merged. Why, and what is one way to fix it?
Show answer
The paths filter means the workflow does not run, so the required "test" check never reports and stays "Expected". Fix it by removing the paths filter so the workflow always runs, or by adding a second always-running workflow or job that reports the same check name.
Exercise
A matrix of three Node.js versions shows one red job and two grey "cancelled" jobs. What setting caused the cancellations, and how do you change it?
Show answer
fail-fast defaults to true, so the first failure cancels the other matrix jobs. Set fail-fast: false under strategy to let every combination finish.