Refactor Microsoft JDK installer to fetch version information from Microsoft Learn

- Removed dependency on static JSON file for version info
- Implemented HTML parsing to dynamically retrieve available JDK versions
- Updated unit tests to reflect new version fetching method
- Revised documentation to reflect changes in version retrieval and network requirements
- Deleted outdated JSON file as it is no longer needed
This commit is contained in:
Steve Lohr 2025-10-02 16:08:25 +02:00
commit 3524b5fb29
7 changed files with 4790 additions and 5232 deletions

View file

@ -92,20 +92,24 @@ steps:
### Using Microsoft distribution on GHES
`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...`.
`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` fetches available versions directly from [Microsoft Learn](https://learn.microsoft.com/en-us/java/openjdk/download) and downloads the JDK from `aka.ms` (Microsoft's content delivery network).
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:
**Note:** As of October 2025, the action no longer uses the GitHub API to fetch version information, eliminating previous rate-limiting issues when determining available Microsoft JDK versions. The action now:
- Fetches version information directly from Microsoft Learn documentation
- Downloads JDK binaries from Microsoft's CDN (`aka.ms/download-jdk`)
- Automatically detects the latest available versions without manual updates
If the runner is not able to access `learn.microsoft.com` or `aka.ms`, 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.
For air-gapped environments, you can pre-populate the tool cache with Microsoft JDK releases:
```yaml
uses: actions/setup-java@v5
with:
token: ${{ secrets.GH_DOTCOM_TOKEN }}
distribution: 'microsoft'
java-version: '21'
```
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.