DEV Community

Discussion on: Run your Github Actions jobs from a specific directory

Collapse
 
spydon profile image
Lukas Klingsbo

This doesn't work for uses unfortunately.

Collapse
 
seriosus profile image
Alekz

uses is for linking a repo, which works in its own directories, that is what is supposed to happen, that's why you cant use working-directory with uses

Collapse
 
corleroux profile image
Cor le Roux

For anyone struggling with the Node Setup action step, specifically with the uses section when your project is in a sub-folder, you need to add a cache-dependency-path to the with section.

Example:


 - uses: actions/setup-node@v2
  with:
    node-version: '14'
    cache: 'npm'
    cache-dependency-path: subdir/package-lock.json`
Enter fullscreen mode Exit fullscreen mode
Collapse
 
rickychongjl profile image
rickychongjl • Edited

To add to this, if your package.lock.json is in another directory, this would most probably mean that you need to target npm build command to that particular directory by adding the default-directory syntax on your steps or job (depending on your setup)

npm:
runs-on: windows-latest
defaults:
run:
working-directory: ./subdir/
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: ./subdir/package-lock.json