Sub topic 14
Troubleshooting and design guidelines
This chapter assumes you can write a basic workflow and have read the earlier chapters on workflow_call, inputs, secrets, outputs, permissions, versioning and nesting. It collects the errors you are most likely to hit and the design rules that prevent them.
A debugging order that works
Most failures fall into one of four groups. Check them in this order.
- The call does not start. The caller run fails at validation, before any job runs.
- The call starts but a value is empty. An input, secret or output is missing.
- The call runs but is denied. A permission or access setting blocks it.
- The call behaves differently from a direct run. The caller context is not what you assumed.
Failures at validation
If the caller run fails immediately, look at these causes:
- The called file has no
on: workflow_call. It cannot be called. - The
usespath is wrong. Remote calls needowner/repo/.github/workflows/file.yml@ref. Same-repository calls use./.github/workflows/file.ymlwith no@ref. - The ref does not exist, for example
@v1before the tag was pushed. - The called repository does not allow access. A private repository must permit workflow access from the calling repository in its Actions settings.
- A required input or required secret was not supplied.
- A
usesjob has steps. A job that calls a workflow cannot also havestepsorruns-on.
Values that arrive empty
A missing input falls back to its default. If there is no default, the value is empty. A missing optional secret is also empty, with no error. Two mistakes are common.
- Secrets across
workflow_call. A called workflow cannot read the caller's secrets unless they are passed withsecrets:orsecrets: inherit. Environment-level secrets are the exception: they belong to the environment, not the caller. - Outputs. An output needs three links: a step writes to
GITHUB_OUTPUT, the job lists it underoutputs, andworkflow_call.outputsmaps the job output. If any link is missing, the caller gets an empty string. The caller must also list the calling job inneeds.
jobs:
announce:
needs: build
runs-on: ubuntu-latest
steps:
- run: echo "Artifact is '${{ needs.build.outputs.artifact-name }}'"Quoting the value in echo, as above, makes an empty output easy to see in the log.
Access denied
The called workflow can keep or reduce the GITHUB_TOKEN permissions it receives, but it cannot raise them. If a step reports Resource not accessible by integration, set permissions: on the calling job, as shown in the permissions chapter. Setting them inside the called workflow alone does not help when the caller grants less.
Different behavior from a direct run
The github context in a called workflow describes the caller. So github.repository is the calling repository, and github.workflow is the caller's workflow name. Steps that use actions/checkout check out the caller's repository by default. If the called workflow needs its own helper scripts, check them out explicitly with repository: and ref:.
Also remember the limits: nesting depth is capped, and a workflow cannot call itself in a loop. A nested call cannot receive more permissions than its parent. Environment variables set with env in the caller are not passed to the called workflow. Pass them as inputs.
Design guidelines
- Keep the interface small. Every input is a promise to callers. Prefer a few typed inputs with defaults.
- Give inputs a
typeand adescription. Usebooleanandnumberinstead of strings where possible. - Request the least permissions. Declare a
permissions:block in the called workflow so it never depends on defaults. - Prefer named secrets over
secrets: inheritfor workflows in other repositories. Useinheritonly inside one organization you trust. - Pin shared workflows to a tag or a full commit SHA. Use a SHA for workflows you do not control.
- Move a version tag only for compatible changes. Publish
v2for breaking changes. - Use a composite action for a few reusable steps. Use a reusable workflow when you need whole jobs, runners or a matrix.
- Document each workflow in a README next to it, with a copy-ready caller example.
Exercise
A caller job uses build.yml and a later job prints ${{ needs.build.outputs.artifact-name }}. The value is empty, but the build job's step did write to GITHUB_OUTPUT. Name two places in the called workflow where the mapping could be broken.
Show answer
The job must list the value under jobs.<job_id>.outputs, and on.workflow_call.outputs must map it with value: ${{ jobs.<job_id>.outputs.<name> }}. Also check that the step has an id that matches the steps.<id>.outputs reference.
Exercise
A called workflow's step fails with Resource not accessible by integration when it posts a pull request comment. Where do you fix it?
Show answer
Add permissions: pull-requests: write (plus contents: read) to the calling job. The called workflow cannot raise permissions above what the caller grants.