From 788c6ccbd0d6bddb637da16397c675d9e1c6f93c Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 17 Oct 2022 12:23:04 +0200 Subject: [PATCH 1/3] remove node-version 12 from matrix (#594) --- .github/workflows/e2e-cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml index 87d6d4d3..fab3dcd7 100644 --- a/.github/workflows/e2e-cache.yml +++ b/.github/workflows/e2e-cache.yml @@ -75,7 +75,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version: [12, 14, 16] + node-version: [14, 16] steps: - uses: actions/checkout@v3 - name: Yarn version From 16352bb09bc672a073e326c2cc1d3d7d2a3e577e Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 25 Oct 2022 16:37:59 +0200 Subject: [PATCH 2/3] Get rid of warnings for set-output (#607) --- .github/workflows/versions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 9a138ebb..0472e64b 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -178,7 +178,7 @@ jobs: - name: Get node version run: | latestNodeVersion=$(curl https://nodejs.org/dist/index.json | jq -r '. [0].version') - echo "::set-output name=LATEST_NODE_VERSION::$latestNodeVersion" + echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT id: version shell: bash - uses: actions/checkout@v3 @@ -189,7 +189,7 @@ jobs: - name: Retrieve version after install run: | updatedVersion=$(echo $(node --version)) - echo "::set-output name=NODE_VERSION_UPDATED::$updatedVersion" + echo "NODE_VERSION_UPDATED=$updatedVersion" >> $GITHUB_OUTPUT id: updatedVersion shell: bash - name: Compare versions From 00e1b6691b40cce14b5078cb411dd1ec7dab07f7 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 2 Nov 2022 12:24:44 +0100 Subject: [PATCH 3/3] Pass the token input through on GHES (#595) --- README.md | 15 +++++++++++++++ action.yml | 4 ++-- dist/setup/index.js | 2 +- src/main.ts | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c3d07869..3d9d7eeb 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,21 @@ jobs: - run: npm test ``` +## Using `setup-node` on GHES + +`setup-node` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Nodejs distributions, `setup-node` downloads distributions from [`actions/node-versions`](https://github.com/actions/node-versions) on github.com (outside of the appliance). These calls to `actions/node-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If more requests are made within the time frame, then you will start to see rate-limit errors during downloading that looks like: `##[error]API rate limit exceeded for...`. After that error the action will try to download versions directly from the official site, but it also can have rate limit so it's better to put token. + +To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action: + +```yaml +uses: actions/setup-node@v3 +with: + token: ${{ secrets.GH_DOTCOM_TOKEN }} + node-version: 16 +``` + +If the runner is not able to access github.com, any Nodejs versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information. + ## Advanced usage 1. [Check latest version](docs/advanced-usage.md#check-latest-version) diff --git a/action.yml b/action.yml index ae2e8243..b22de1ef 100644 --- a/action.yml +++ b/action.yml @@ -19,8 +19,8 @@ inputs: scope: description: 'Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).' token: - description: Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. - default: ${{ github.token }} + description: Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. + default: ${{ github.server_url == 'https://github.com' && github.token || '' }} cache: description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.' cache-dependency-path: diff --git a/dist/setup/index.js b/dist/setup/index.js index 0daaa2f2..54623f04 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -73628,7 +73628,7 @@ function run() { } if (version) { let token = core.getInput('token'); - let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`; + let auth = !token ? undefined : `token ${token}`; let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE'; const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE'; yield installer.getNode(version, stable, checkLatest, auth, arch); diff --git a/src/main.ts b/src/main.ts index 6a980a0d..2107c955 100644 --- a/src/main.ts +++ b/src/main.ts @@ -33,7 +33,7 @@ export async function run() { if (version) { let token = core.getInput('token'); - let auth = !token || isGhes() ? undefined : `token ${token}`; + let auth = !token ? undefined : `token ${token}`; let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE'; const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';