Skip to content

Commit b029468

Browse files
ci: make sure semver is available in script (#372)
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com> Co-authored-by: Chan <bot+chan@asyncapi.io>
1 parent 10de35a commit b029468

File tree

1 file changed

+10
-3
lines changed
  • .github/actions/get-node-version-from-package-lock

1 file changed

+10
-3
lines changed

.github/actions/get-node-version-from-package-lock/action.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ outputs:
1111
runs:
1212
using: "composite"
1313
steps:
14-
- name: Install semver package
14+
- name: Install semver package in temporary location
1515
shell: bash
16-
run: npm install -g semver@7.7.3
16+
run: |
17+
# Install semver in runner's temp directory to avoid polluting the repository
18+
# and interfering with project dependencies. actions/github-script can require
19+
# packages using absolute paths, so we resolve $RUNNER_TEMP path in the script.
20+
mkdir -p "$RUNNER_TEMP/github-script-deps"
21+
cd "$RUNNER_TEMP/github-script-deps"
22+
npm install semver@7.7.3 --no-package-lock --no-save
1723
1824
- name: Get Node version
1925
uses: actions/github-script@v8
@@ -25,7 +31,8 @@ runs:
2531
script: |
2632
const { resolve } = require('path');
2733
const { access, constants } = require('fs').promises;
28-
const semver = require('semver');
34+
const semverPath = resolve(process.env.RUNNER_TEMP, 'github-script-deps/node_modules/semver');
35+
const semver = require(semverPath);
2936
3037
// Priority 1: Check for input override (e.g. vars.NODE_VERSION passed from caller)
3138
const envNodeVersion = process.env.OVERRIDE_NODE_VERSION;

0 commit comments

Comments
 (0)