-
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?
Conversation
71ad361
to
c75217f
Compare
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 comment
The 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.
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT | ||
fi | ||
shell: bash | ||
- uses: actions/setup-node@v4 |
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
id: setup-node | ||
if: steps.get-node-version.outputs.node_version | ||
with: | ||
node-version: ${{ steps.get-node-version.outputs.node_version }} |
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.
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:
diff --git a/action.yaml b/action.yaml
index 6dcc903..8a78d82 100644
--- a/action.yaml
+++ b/action.yaml
@@ -3,6 +3,11 @@ description:
GitHub Action that installs and provisions supported tools for workflow steps
in self-hosted runners. This relies on the agent having supported tooling
installed.
+inputs:
+ github-token:
+ required: true
+ description: GitHub token to overcome unauthenticated rate limits when installing node, for instance 'secrets.GITHUB_TOKEN'
+ default: ${{ github.token }}
outputs:
go:
description:
@@ -44,6 +49,8 @@ runs:
if: steps.get-node-version.outputs.node_version
with:
node-version: ${{ steps.get-node-version.outputs.node_version }}
+ # https://github.com/actions/setup-node?tab=readme-ov-file#using-setup-node-on-ghes
+ token: ${{ inputs.github-token }}
- name: Export installed node version
if: steps.get-node-version.outputs.node_version
run: |
c75217f
to
690ac13
Compare
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 comment
The 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 comment
The 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)
Description
We'd like to explore reusing actions/setup-node as our custom implementation is flaky on new node version requests.
Changes
🚀 PR created with fotingo