Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make updated npm version more accurate in action logs #38

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Changes from all 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
20 changes: 15 additions & 5 deletions .github/workflows/nodejs-test-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,31 @@ jobs:
node-version: ${{ inputs.node-version }}
cache: npm

- name: Update npm to latest
- name: Get npm version
id: npm-version
shell: bash
run: |
case $(node -v) in
v16.*|v14.*|v12.*|v10.*)
npm install --global npm@9
major_version=9
;;
v18.*)
npm install --global npm@10
major_version=10
;;
*)
npm install --global npm@latest
echo "latest=true" >> "${GITHUB_OUTPUT}"
echo "version=$(npm view npm version)" >> "${GITHUB_OUTPUT}"
exit 0
;;
esac
echo "Successfully updated npm to $(npm -v)"
version=$(npm view "npm@${major_version}" version --json | jq -r '.[-1]')
echo "version=${version}" >> "${GITHUB_OUTPUT}"

- name: Update npm to ${{ steps.npm-version.outputs.version }}${{ steps.npm-version.outputs.latest && ' (latest)' }}
shell: bash
env:
npm_version: ${{ steps.npm-version.outputs.version }}
run: npm install --global "npm@${npm_version}"

- name: Install dependencies
run: npm ci
Expand Down
Loading