How to debug GitHub Actions failures?
· Category: DevOps & CI/CD
Short answer
Debug GitHub Actions by examining job logs, reproducing locally, enabling step debugging, and using the workflow commands to inspect the environment.
Steps
- Read the job logs for error messages.
- Reproduce the failure locally or with
act. - Enable debug logging by setting
ACTIONS_STEP_DEBUG. - Add debug steps to print environment variables.
Example
steps:
- run: env
- run: cat $GITHUB_EVENT_PATH
- run: ls -la
Tips
- Use
jobs.<job_id>.ifto skip unaffected jobs during debugging. - Use
workflow_dispatchinputs to control behavior. - Use
tmateaction for interactive debugging on the runner.
Common issues
- Environment differences between runners and local machines cause failures.
- Secrets are not available in pull requests from forks.
- YAML syntax errors prevent workflows from starting.
- Outdated actions cause deprecation warnings or failures.