@@ -10,24 +10,27 @@ outputs:
1010runs :
1111 using : " composite"
1212 steps :
13- - name : Setup sandboxed dependencies
13+ - name : Setup sandbox for github-script
1414 shell : bash
1515 run : |
16- npm init -y --prefix ${{ github.action_path }} >/dev/null 2>&1
17- npm install semver --prefix ${{ github.action_path }} >/dev/null 2>&1
16+ cd ${{ github.action_path }}
17+ mkdir temp
18+ cd temp
19+ npm init -y
20+ npm install semver
1821
1922 - name : Find version script
2023 id : get-node-version
21- uses : actions/github-script@v7
24+ uses : actions/github-script@v8
2225 with :
2326 script : |
2427 const path = require('path');
2528 const fs = require('fs');
2629 // Load the sandboxed semver dependency from the action's own node_modules
27- const semver = require(path.join(process.env.GITHUB_ACTION_PATH, 'node_modules/semver'));
30+ const semver = require(path.join(process.env.GITHUB_ACTION_PATH, 'temp/ node_modules/semver'));
2831
2932 const defaultVersion = '20.9';
30-
33+
3134 // Define the versions to check against the package.json engines field, in order of preference
3235 // See https://github.com/actions/node-versions/releases for available versions
3336 const versionsToCheck = [defaultVersion, '24.9'].map((v) => semver.minVersion(v).version);
3740 core.setFailed(`Error: package.json not found at ${packageJsonPath}`);
3841 return;
3942 }
40-
43+
4144 const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
4245 const requiredRange = packageJson.engines?.node;
4346
5659
5760 core.setFailed(`\nNo compatible Node.js version found in the list of versions "${versionsToCheck.join(', ')}" for range "${requiredRange}". Returning default version ${defaultVersion}.`);
5861 return defaultVersion;
62+
63+ - name : Cleanup sandbox
64+ shell : bash
65+ run : |
66+ cd ${{ github.action_path }}
67+ rm -rf temp
0 commit comments