Skip to content

Commit aed1abf

Browse files
committed
feat: create sandbox for github-script in get-node-version
1 parent 133076a commit aed1abf

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

.github/actions/build-node-python/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ runs:
119119
shell: bash
120120
# Python
121121
- name: Set up python
122-
uses: actions/setup-python@v5
122+
uses: actions/setup-python@v6
123123
if: inputs.enable_python == 'true'
124124
with:
125125
python-version: ${{ inputs.python_version || '3.10' }}

.github/actions/get-node-version/action.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@ outputs:
1010
runs:
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);
@@ -37,7 +40,7 @@ runs:
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
@@ -56,3 +59,9 @@ runs:
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

.github/workflows/build-node-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ on:
110110
required: false
111111

112112
env:
113-
WORKFLOW_BRANCH: "mp/node_version"
113+
WORKFLOW_BRANCH: "main"
114114
POSTGRES_HOSTNAME: postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
115115

116116
permissions:

0 commit comments

Comments
 (0)