Skip to content

Commit 27b43e1

Browse files
Pass the token input through on GHES (#277)
1 parent c4a742c commit 27b43e1

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,21 @@ The `go-version` input supports the following syntax:
169169

170170
For more information about semantic versioning, please refer to [semver](https://github.com/npm/node-semver) documentation.
171171

172+
## Using `setup-go` on GHES
173+
174+
`setup-go` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Go distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) on github.com (outside of the appliance). These calls to `actions/go-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 https://storage.googleapis.com/golang, but it also can have rate limit so it's better to put token.
175+
176+
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:
177+
178+
```yaml
179+
uses: actions/setup-go@v3
180+
with:
181+
token: ${{ secrets.GH_DOTCOM_TOKEN }}
182+
go-version: 1.18
183+
```
184+
185+
If the runner is not able to access github.com, any Go 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/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information.
186+
172187
# License
173188

174189
The scripts and documentation in this project are released under the [MIT License](LICENSE)

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ inputs:
1010
description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec'
1111
default: false
1212
token:
13-
description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user.
14-
default: ${{ github.token }}
13+
description: Used to pull node distributions from go-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.
14+
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
1515
cache:
1616
description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
1717
default: false

dist/setup/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63519,7 +63519,7 @@ function run() {
6351963519
}
6352063520
if (versionSpec) {
6352163521
let token = core.getInput('token');
63522-
let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`;
63522+
let auth = !token ? undefined : `token ${token}`;
6352363523
const checkLatest = core.getBooleanInput('check-latest');
6352463524
const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch);
6352563525
core.addPath(path_1.default.join(installDir, 'bin'));

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function run() {
2828

2929
if (versionSpec) {
3030
let token = core.getInput('token');
31-
let auth = !token || isGhes() ? undefined : `token ${token}`;
31+
let auth = !token ? undefined : `token ${token}`;
3232

3333
const checkLatest = core.getBooleanInput('check-latest');
3434
const installDir = await installer.getGo(

0 commit comments

Comments
 (0)