Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions actions/get-package-manager/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,26 @@ runs:
}

let relativeWorkingDirectory = path.relative(process.env.GITHUB_WORKSPACE, workingDirectory) || '.';
let isOutsideWorkspace = false;

if (relativeWorkingDirectory.startsWith('../')) {
relativeWorkingDirectory = path.resolve(workingDirectory);
core.warning(`Working directory "${workingDirectory}" is outside GITHUB_WORKSPACE. Caching will be disabled for setup-node.`);
isOutsideWorkspace = true;
}

const packageManagerConfig = {
yarn: {
cacheDependencyPath: `${relativeWorkingDirectory}/**/yarn.lock`,
cacheDependencyPath: isOutsideWorkspace ? '' : `${relativeWorkingDirectory}/**/yarn.lock`,
installCommand: 'yarn install --frozen-lockfile',
runScriptCommand: 'yarn',
},
pnpm: {
cacheDependencyPath: `${relativeWorkingDirectory}/**/pnpm-lock.yaml`,
cacheDependencyPath: isOutsideWorkspace ? '' : `${relativeWorkingDirectory}/**/pnpm-lock.yaml`,
installCommand: 'pnpm install --frozen-lockfile',
runScriptCommand: 'pnpm',
},
npm: {
cacheDependencyPath: `${relativeWorkingDirectory}/**/package-lock.json`,
cacheDependencyPath: isOutsideWorkspace ? '' : `${relativeWorkingDirectory}/**/package-lock.json`,
installCommand: 'npm ci',
runScriptCommand: 'npm run',
},
Expand Down
2 changes: 1 addition & 1 deletion actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ runs:
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version-file: ${{ steps.get-node-version-file.outputs.node-version-file }}
cache: ${{ steps.get-package-manager.outputs.package-manager }}
cache: ${{ steps.get-package-manager.outputs.cache-dependency-path != '' && steps.get-package-manager.outputs.package-manager || '' }}
cache-dependency-path: ${{ steps.get-package-manager.outputs.cache-dependency-path }}

- shell: bash
Expand Down