1
0
Fork 0
mirror of https://github.com/actions/setup-go synced 2024-12-22 14:22:41 +00:00

Pass the token input through on GHES (#277)

This commit is contained in:
Dmitry Shibanov 2022-11-02 12:21:18 +01:00 committed by GitHub
parent c4a742cab1
commit 27b43e1b0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View file

@ -169,6 +169,21 @@ The `go-version` input supports the following syntax:
For more information about semantic versioning, please refer to [semver](https://github.com/npm/node-semver) documentation. For more information about semantic versioning, please refer to [semver](https://github.com/npm/node-semver) documentation.
## Using `setup-go` on GHES
`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.
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-go@v3
with:
token: ${{ secrets.GH_DOTCOM_TOKEN }}
go-version: 1.18
```
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/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.
# License # License
The scripts and documentation in this project are released under the [MIT License](LICENSE) The scripts and documentation in this project are released under the [MIT License](LICENSE)

View file

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

2
dist/setup/index.js vendored
View file

@ -63519,7 +63519,7 @@ function run() {
} }
if (versionSpec) { if (versionSpec) {
let token = core.getInput('token'); let token = core.getInput('token');
let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`; let auth = !token ? undefined : `token ${token}`;
const checkLatest = core.getBooleanInput('check-latest'); const checkLatest = core.getBooleanInput('check-latest');
const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch);
core.addPath(path_1.default.join(installDir, 'bin')); core.addPath(path_1.default.join(installDir, 'bin'));

View file

@ -28,7 +28,7 @@ export async function run() {
if (versionSpec) { if (versionSpec) {
let token = core.getInput('token'); let token = core.getInput('token');
let auth = !token || isGhes() ? undefined : `token ${token}`; let auth = !token ? undefined : `token ${token}`;
const checkLatest = core.getBooleanInput('check-latest'); const checkLatest = core.getBooleanInput('check-latest');
const installDir = await installer.getGo( const installDir = await installer.getGo(