Skip to content

Commit 00e1b66

Browse files
Pass the token input through on GHES (#595)
1 parent 16352bb commit 00e1b66

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,21 @@ jobs:
111111
- run: npm test
112112
```
113113

114+
## Using `setup-node` on GHES
115+
116+
`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.
117+
118+
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:
119+
120+
```yaml
121+
uses: actions/setup-node@v3
122+
with:
123+
token: ${{ secrets.GH_DOTCOM_TOKEN }}
124+
node-version: 16
125+
```
126+
127+
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.
128+
114129
## Advanced usage
115130

116131
1. [Check latest version](docs/advanced-usage.md#check-latest-version)

action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ inputs:
1919
scope:
2020
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/).'
2121
token:
22-
description: Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user.
23-
default: ${{ github.token }}
22+
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.
23+
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
2424
cache:
2525
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.'
2626
cache-dependency-path:

dist/setup/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73628,7 +73628,7 @@ function run() {
7362873628
}
7362973629
if (version) {
7363073630
let token = core.getInput('token');
73631-
let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`;
73631+
let auth = !token ? undefined : `token ${token}`;
7363273632
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
7363373633
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
7363473634
yield installer.getNode(version, stable, checkLatest, auth, arch);

src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function run() {
3333

3434
if (version) {
3535
let token = core.getInput('token');
36-
let auth = !token || isGhes() ? undefined : `token ${token}`;
36+
let auth = !token ? undefined : `token ${token}`;
3737
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
3838
const checkLatest =
3939
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';

0 commit comments

Comments
 (0)