When a GitHub Actions workflow fails, the visible error is often only the final symptom. This guide provides a repeatable way to separate YAML errors, permissions problems, missing secrets, runner differences, cache issues, matrix behavior, and artifact failures. It also includes a diagnostic workflow you can reuse, a tracking checklist for recurring failures, and a maintenance cadence for keeping CI workflows understandable.
Overview
A GitHub Actions workflow can behave differently from a local build because it runs in a separate environment with its own operating system, shell, filesystem, credentials, tools, and event context. Troubleshooting is faster when you first classify the failure instead of changing several workflow lines at once.
Start with the failed job, then identify the first meaningful error in its log. The last red line may be a cleanup message or a consequence of an earlier failure. Record the event that triggered the run, the branch or commit, the runner label, the job name, and whether the failure is reproducible.
| Failure category | Typical clue | First check |
|---|---|---|
| YAML or expression syntax | The workflow is rejected before a job starts | Indentation, keys, brackets, expressions, and event configuration |
| Permissions | Checkout, release, issue, or package operation returns an authorization error | Token permissions, repository settings, and the event type |
| Secrets | A credential appears empty or authentication fails | Secret name, scope, fork behavior, environment approval, and masking |
| Runner environment | A command works locally but a tool or path is missing in CI | Operating system, installed tools, shell, architecture, and versions |
| Working directory | A file or package cannot be found | Repository checkout path, current directory, and relative paths |
| Cache | Restored dependencies are stale, incomplete, or unexpectedly absent | Cache key, dependency lockfile, path, and restore behavior |
| Matrix jobs | Only one operating system, runtime, or version fails | Expanded matrix values and job-specific conditions |
| Artifacts | Upload or download succeeds but files are missing | Artifact path, job dependency, retention expectations, and naming |
This classification is useful for both an isolated incident and a recurring CI review. It prevents a cache miss from being treated as a compiler defect or a missing permission from being mistaken for a broken deployment script.
What to track
1. Workflow and event context
Keep a small record of each workflow’s purpose, trigger, required permissions, runner label, and critical external services. A pull request run may have different secrets or write access from a trusted branch run, so always record the event that produced the failure. Check whether the run came from a fork, a scheduled trigger, a manual dispatch, or a reusable workflow call.
2. The first failing command
Capture the step name, command, exit code when available, and the first relevant error. If a step contains a long shell script, split it into smaller steps or add temporary diagnostic output for non-sensitive values. Do not print tokens, private keys, complete connection strings, or secret-derived headers. A useful log explains what was being tested without exposing the credential used to test it.
3. Environment details
Track the runner operating system, language runtime, package manager version, compiler version, shell, and architecture when they affect the build. Pin important tool versions where practical, and make the versions visible in logs. This turns a vague report such as build failed into a comparison between a passing and failing environment.
4. Secrets and permissions
For a GitHub Actions secrets not working report, verify the exact name and scope first. A secret can be repository-level, organization-level, or environment-specific, and a job may need an environment before its values are available. Expressions that reference an unset secret generally do not provide a useful diagnostic value, so test presence without printing the secret itself.
Review the workflow’s permissions block as well as repository settings. Grant only the access required by the job. A read-only checkout job should not receive broad write permissions simply because another job publishes a release.
5. Caches and artifacts
Cache debugging should answer four questions: what is being cached, where is it stored, what inputs invalidate it, and what happens on a miss? Include the lockfile or another dependency input in the key when dependency changes must trigger a new cache. Treat a cache as an optimization, not as the only source of required files. The job should still be able to install dependencies from a clean state.
For artifacts, verify the path from the same working directory used by the build. Make the producing job complete before a consuming job starts, and use clear artifact names when a matrix creates several outputs. A successful upload step does not prove that the intended files were generated; inspect the build output before packaging it.
6. A reusable diagnostic workflow
The following pattern is deliberately small. Add it temporarily to a failing workflow or adapt the commands to the project’s language. It reports context and verifies the checkout without exposing secrets.
name: CI diagnostics
on:
workflow_dispatch:
permissions:
contents: read
jobs:
inspect:
runs-on: ubuntu-latest
steps:
- name: Show runner context
run: |
uname -a
pwd
git --version
node --version || true
python --version || true
- name: Check out source
uses: actions/checkout@v4
- name: Inspect workspace
run: |
printf 'Top-level files:\n'
find . -maxdepth 2 -type f | sort | sed -n '1,80p'
printf 'Git status:\n'
git status --short
- name: Verify required variables without printing values
env:
SAMPLE_TOKEN: ${{ secrets.SAMPLE_TOKEN }}
run: |
if [ -n '$SAMPLE_TOKEN' ]; then
echo 'SAMPLE_TOKEN is available'
else
echo 'SAMPLE_TOKEN is empty or unavailable'
fiUse the current major version and supported syntax for actions in your repository; action versions and runner images can change over time. If a diagnostic job passes while the original job fails, compare permissions, working directories, conditions, matrix values, and environment variables rather than assuming the application code is at fault.
Cadence and checkpoints
Review the workflow after every meaningful change to the build, deployment target, runtime, dependency manager, or action version. A quarterly review is a practical baseline for teams that do not change CI frequently. High-change repositories may benefit from a monthly check.
- Each failure: classify the issue, save the first meaningful error, and record the fix.
- Monthly: look for repeated failures, flaky steps, cache misses, slow jobs, and unnecessary diagnostic output.
- Quarterly: review runner labels, action versions, permissions, secret scopes, artifact paths, and language tool versions.
- Before a release: run the cleanest supported path, confirm required artifacts, and verify that deployment credentials are available only to the intended job.
- After a repository move or security change: recheck secrets, environments, token permissions, webhook-triggered events, and reusable workflow references.
Keep the review checklist near the workflow or in the repository documentation. A short record of symptoms, root cause, and prevention is more valuable than a large collection of copied log output.
How to interpret changes
A failure that begins immediately after a YAML edit is likely structural or expression-related. A failure that appears only for pull requests from forks points toward credentials, permissions, or event context. A failure limited to one matrix entry suggests a tool, platform, or conditional difference. A failure that disappears when the cache is bypassed should prompt a cache-key and cache-path review, but it should not be solved by permanently deleting caching without understanding the cause.
Separate deterministic failures from intermittent ones. Re-run a transient-looking job only after recording the original log. If the same command fails with the same input, focus on configuration or code. If the failure changes between attempts, inspect network calls, external services, concurrency, time-sensitive tests, and shared state. Repeated re-runs can hide a reliability problem and make the workflow appear healthier than it is.
For YAML errors, validate the smallest possible change and check indentation around mappings, lists, multiline commands, and expressions. For working-directory errors, print pwd and list the expected directory before changing paths. For expression errors, confirm the event payload actually contains the property being referenced and use explicit conditions when a value may be absent.
When a failure is caused by a merge or lockfile change, resolve the source conflict carefully and regenerate the lockfile with the project’s normal toolchain. The Git merge conflict workflow can help distinguish source files from generated dependency files. For environment-heavy debugging, compare this process with the Docker Compose environment variable checklist and the SSH configuration troubleshooting guide.
When to revisit
Revisit this checklist whenever GitHub Actions reports a new class of failure, a hosted runner image changes, an action major version changes, or the repository adopts a new runtime, package manager, deployment environment, or security policy. It is also worth reviewing after a migration from one event trigger to another, because event context affects available permissions and secrets.
Make the next investigation easier by leaving the workflow cleaner than you found it. Name steps by purpose, keep permissions close to the job that needs them, document non-obvious cache keys, and make artifact paths explicit. Add a small issue or runbook entry when a failure reveals a recurring weakness.
For the next broken run, follow this sequence: open the failed job, find the first meaningful error, record event and runner context, classify the category, reproduce with a clean checkout where possible, and change one variable at a time. Then update the tracking notes with the cause and prevention. This approach turns GitHub Actions troubleshooting from repeated guesswork into a maintainable developer productivity practice.