Skip to content
Latchkey

How to Set the Working Directory in GitHub Actions

working-directory changes where a run step executes; defaults.run applies it to every step.

Add working-directory: to a step, or set defaults.run.working-directory to apply it across the job.

Steps

  • Add working-directory: to a single step, or
  • Set defaults.run.working-directory: at job level for all steps.
  • Paths are relative to the workspace root.

Workflow

.github/workflows/ci.yml
jobs:
  build:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: packages/web
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run build

Gotchas

  • working-directory applies only to run: steps, not to uses: actions.
  • For uses: actions, pass the path via the action's own input.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →