Skip to content
Latchkey

GitHub Actions Composite Action Ignores working-directory

A composite action runs commands in the wrong directory because working-directory set on the caller’s uses: step does not flow into the action. Each composite run step sets its own working-directory.

What this error means

A composite action’s commands run from the repository root instead of the subdirectory you set on the calling step, causing "file not found" or operating on the wrong path.

.github/workflows/ci.yml
# caller
- uses: ./.github/actions/build
  with: { dir: app }
  working-directory: app   # NOT applied inside the composite action

Common causes

working-directory on uses: does not propagate

working-directory applies to that single step. For a uses: step calling a composite action, it does not change the directory the action’s inner run steps execute in.

Composite steps default to the workspace root

Each composite run step runs from the default workspace unless it sets its own working-directory, so a subdirectory must be passed and applied inside the action.

How to fix it

Set working-directory on each composite run step

Pass the directory as an input and apply it on the inner run steps.

action.yml
# action.yml
inputs:
  dir: { required: true }
runs:
  using: composite
  steps:
    - shell: bash
      working-directory: ${{ inputs.dir }}
      run: npm ci

Or cd inside the run script

  1. Accept the target directory as an input to the composite action.
  2. Apply working-directory on every inner run step, or cd into it at the top of the script.
  3. Do not rely on a working-directory set on the calling uses: step.

How to prevent it

  • Pass the working directory into composite actions as an input.
  • Set working-directory on each inner composite run step.
  • Remember working-directory on a uses: step does not enter the action.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →