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 buildGotchas
working-directoryapplies only torun:steps, not touses:actions.- For
uses:actions, pass the path via the action's own input.
Related guides
How to Set the Default Shell in GitHub ActionsPin the shell for every run step in GitHub Actions with defaults.run.shell, so scripts behave consistently ac…
How to Run Only on Changed Paths in GitHub ActionsTrigger a GitHub Actions workflow only when specific files change using on.push.paths, avoiding wasted runs i…