-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: now uses actions/setup-node #246
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ outputs: | |
The version of golang that has been installed and is ready for use. | ||
node: | ||
description: | ||
The verison of Node.js that has been installed and is ready for use. | ||
The version of Node.js that has been installed and is ready for use. | ||
java: | ||
description: | ||
The version of Java that has been installed and is ready for use. | ||
|
@@ -20,5 +20,42 @@ outputs: | |
description: | ||
The version of Terraform that has been installed and is ready for use. | ||
runs: | ||
using: "node20" | ||
main: "dist/main/index.js" | ||
using: "composite" | ||
steps: | ||
- name: Read node version | ||
id: get-node-version | ||
run: | | ||
# Check if an .nvmrc file exists and export the node version if it does | ||
if [ -f .nvmrc ]; then | ||
NODE_VERSION=$(cat .nvmrc) | ||
echo "Node version from .nvmrc: $NODE_VERSION" | ||
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT | ||
fi | ||
# Check if a .node-version file exists and export the node version if it does | ||
if [ -f .node-version ]; then | ||
NODE_VERSION=$(cat .node-version) | ||
echo "Node version from .node-version: $NODE_VERSION" | ||
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT | ||
fi | ||
shell: bash | ||
- uses: actions/setup-node@v4 | ||
id: setup-node | ||
if: steps.get-node-version.outputs.node_version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this POC, we only install node if it is required, otherwise we fall back to the system node. We could as easily install node 20 as the default and run the node install step every time. We can make a decision here. |
||
with: | ||
node-version: ${{ steps.get-node-version.outputs.node_version }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can optionally provide a GH token if we hit rate limits (https://github.com/actions/setup-node?tab=readme-ov-file#using-setup-node-on-ghes) We just need to apply this diff:
|
||
- name: Install yarn | ||
if: steps.setup-node.outputs.node-version | ||
run: | | ||
npm install -g yarn | ||
shell: bash | ||
- name: Export installed node version | ||
if: steps.get-node-version.outputs.node_version | ||
run: | | ||
echo "Installed Node version: ${{ steps.setup-node.outputs.node-version }}" | ||
echo "node=${{ steps.setup-node.outputs.node-version }}" >> $GITHUB_OUTPUT | ||
shell: bash | ||
- name: Install Tools | ||
id: install-tools | ||
run: "node ${{ github.action_path }}/dist/main/index.js" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this work if no node version was installed on the previous step? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would work on the github runners, but on self hosted runners this would require having node installed there. In both cases this would run using the default node verison in the runners, which could lead to failures (especially on our internal runners) |
||
shell: bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this action we get cached versions out of the box and a more reliable infrastructure that doesn't require us to rebuild runners to cache new node versions: https://github.com/actions/setup-node