From b5bfbd2bba87883b5965faf03fd1bb73858a9c75 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 17 Oct 2022 13:03:02 +0200 Subject: [PATCH 1/3] pass the token input through on GHES --- dist/setup/index.js | 3 ++- src/distributions/microsoft/installer.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index fe776b93e..f6e0aaf1e 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -104538,6 +104538,7 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { // TODO get these dynamically! // We will need Microsoft to add an endpoint where we can query for versions. const token = core.getInput('token'); + const auth = !token ? undefined : `token ${token}`; const owner = 'actions'; const repository = 'setup-java'; const branch = 'main'; @@ -104545,7 +104546,7 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { let releases = null; const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`; const headers = { - authorization: token, + authorization: auth, accept: 'application/vnd.github.VERSION.raw' }; let response = null; diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index 6284f961c..6929fb2ee 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -73,6 +73,7 @@ export class MicrosoftDistributions extends JavaBase { // TODO get these dynamically! // We will need Microsoft to add an endpoint where we can query for versions. const token = core.getInput('token'); + const auth = !token ? undefined : `token ${token}`; const owner = 'actions'; const repository = 'setup-java'; const branch = 'main'; @@ -82,7 +83,7 @@ export class MicrosoftDistributions extends JavaBase { const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`; const headers: OutgoingHttpHeaders = { - authorization: token, + authorization: auth, accept: 'application/vnd.github.VERSION.raw' }; From 875a6affd950e4f6c1d5d6e082ae62d3d2a12b42 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 26 Oct 2022 14:09:22 +0200 Subject: [PATCH 2/3] update documentation and action.yml --- action.yml | 4 ++-- docs/advanced-usage.md | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 3ace2c663..a6fabc382 100644 --- a/action.yml +++ b/action.yml @@ -59,8 +59,8 @@ inputs: description: 'Workaround to pass job status to post job step. This variable is not intended for manual setting' default: ${{ job.status }} token: - description: Used to pull java versions from setup-java. Since there is a default value, token is typically not supplied by the user. - default: ${{ github.token }} + description: Used to pull java versions from setup-java. Since there is a default value, token 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 || '' }} mvn-toolchain-id: description: 'Name of Maven Toolchain ID if the default name of "${distribution}_${java-version}" is not wanted. See examples of supported syntax in Advanced Usage file' required: false diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 93ebd8548..6c6e95f24 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -80,6 +80,22 @@ steps: - run: java -cp java HelloWorldApp ``` +### Using Microsoft distribution on GHES + +`setup-java` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Microsoft Build of OpenJDK distribution, `setup-java` makes request to `actions/setup-java` to get available versions on github.com (outside of the appliance). These calls to `actions/setup-java` 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...`. + +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-java@v3 +with: + token: ${{ secrets.GH_DOTCOM_TOKEN }} + distribution: 'microsoft' + java-version: '11' +``` + +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. + ### Amazon Corretto **NOTE:** Amazon Corretto only supports the major version specification. From f8290433f5be6e36ca4060dd53cc1254238b033a Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 9 Nov 2022 22:45:57 +0100 Subject: [PATCH 3/3] fix documentation --- action.yml | 2 +- docs/advanced-usage.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index a6fabc382..f67c642d3 100644 --- a/action.yml +++ b/action.yml @@ -59,7 +59,7 @@ inputs: description: 'Workaround to pass job status to post job step. This variable is not intended for manual setting' default: ${{ job.status }} token: - description: Used to pull java versions from setup-java. Since there is a default value, token 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. + description: The token used to authenticate when fetching version manifests hosted on github.com, such as for the Microsoft Build of OpenJDK. 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 || '' }} mvn-toolchain-id: description: 'Name of Maven Toolchain ID if the default name of "${distribution}_${java-version}" is not wanted. See examples of supported syntax in Advanced Usage file' diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 6c6e95f24..3440dffb6 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -82,7 +82,7 @@ steps: ### Using Microsoft distribution on GHES -`setup-java` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Microsoft Build of OpenJDK distribution, `setup-java` makes request to `actions/setup-java` to get available versions on github.com (outside of the appliance). These calls to `actions/setup-java` 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...`. +`setup-java` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading the Microsoft Build of OpenJDK distribution, `setup-java` makes a request to `actions/setup-java` to get available versions on github.com (outside of the appliance). These calls to `actions/setup-java` 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...`. 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: @@ -94,7 +94,7 @@ with: java-version: '11' ``` -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. +If the runner is not able to access github.com, any Java 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. ### Amazon Corretto **NOTE:** Amazon Corretto only supports the major version specification.