-
Notifications
You must be signed in to change notification settings - Fork 625
feat: add support for custom go-download-site input #687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This adds a new `go-download-site` input parameter that allows users to specify a custom base URL for downloading Go distributions. This is particularly useful for GitHub Enterprise Server (GHES) environments, corporate proxies, or air-gapped setups where direct access to github.com is restricted. Changes: - Added `go-download-site` input to `action.yml` (default: `https://github.com`) - Updated `installer.ts` to replace the default GitHub URL with the provided custom site URL - Updated `main.ts` to pass the input to the installer - Added documentation in `README.md` with examples for Artifactory and GHES proxies Resolves actions#296
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for custom Go distribution download sites through a new go-download-site input parameter. This feature enables users in restricted network environments (GitHub Enterprise Server, corporate proxies, air-gapped setups) to specify alternative base URLs for downloading Go distributions from mirrored repositories.
Key Changes:
- Adds
go-download-siteinput parameter with default valuehttps://github.com - Implements URL replacement logic in the installer to use custom download sites for manifest-based distributions
- Provides comprehensive documentation with examples for Artifactory and GHES proxy configurations
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| action.yml | Adds the new go-download-site input parameter with default value and description |
| src/main.ts | Retrieves the go-download-site input and passes it to the installer |
| src/installer.ts | Threads the goDownloadSite parameter through the call chain and implements URL replacement in getInfoFromManifest() |
| README.md | Adds comprehensive documentation section explaining the feature, use cases, requirements, and examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| ``` | ||
| https://internal-artifactory.company.com/github-proxy/actions/go-versions/releases/download/1.21.13-10277905115/go-1.21.13-linux-x64.tar.gz | ||
| ``` | ||
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example URL https://internal-artifactory.company.com/github-proxy should clarify whether it should end with a trailing slash or not. The implementation uses simple string replacement, so the URL format must exactly match how GitHub structures its URLs. Consider adding a note:
"Important: The custom download site URL should not include a trailing slash, as it directly replaces https://github.com in the full download URL path."
| **Important:** The custom download site URL should not include a trailing slash, as it directly replaces `https://github.com` in the full download URL path. |
| info.resolvedVersion = rel.version; | ||
| info.downloadUrl = rel.files[0].download_url; | ||
| // Replace the default github.com URL with the custom download site | ||
| info.downloadUrl = rel.files[0].download_url.replace('https://github.com', goDownloadSite); |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL replacement has two potential issues:
-
String replace is not precise: Using
replace()with a string will replace any occurrence of 'https://github.com' in the URL, not just at the beginning. Use a regex with^anchor for safety. -
No trailing slash handling: If
goDownloadSiteends with a trailing slash, the result will have a double slash (e.g.,https://example.com//actions/...).
Suggested fix:
const normalizedSite = goDownloadSite.replace(/\/$/, '');
info.downloadUrl = rel.files[0].download_url.replace(/^https:\/\/github\.com/, normalizedSite);This ensures only the base URL is replaced and handles trailing slashes gracefully.
| info.downloadUrl = rel.files[0].download_url.replace('https://github.com', goDownloadSite); | |
| const normalizedSite = goDownloadSite.replace(/\/$/, ''); | |
| info.downloadUrl = rel.files[0].download_url.replace(/^https:\/\/github\.com/, normalizedSite); |
| - run: go version | ||
| ``` | ||
| > **Note:** The `go-download-site` parameter only affects downloads from the go-versions repository. Direct downloads from go.dev (fallback mechanism) are not affected by this setting. |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This note indicates that the go-download-site parameter doesn't affect fallback downloads from go.dev, but the implementation in installer.ts only modifies manifest-based downloads. Consider clarifying that:
- The parameter only affects downloads from the go-versions repository manifest
- When manifest downloads fail, the action falls back to go.dev without using the custom download site
- This limitation means truly air-gapped environments may still encounter issues if manifest downloads aren't available
This could be made clearer to help users understand when they might still need additional configuration for fully restricted environments.
| > **Note:** The `go-download-site` parameter only affects downloads from the go-versions repository. Direct downloads from go.dev (fallback mechanism) are not affected by this setting. | |
| > **Note:** The `go-download-site` parameter only affects downloads from the go-versions repository manifest. If manifest-based downloads fail, the action falls back to downloading directly from go.dev, and the custom download site is not used. This means that in truly air-gapped environments, you may still encounter issues if manifest downloads aren't available—additional configuration or pre-caching is required for fully restricted environments. |
| Your custom download site must: | ||
| 1. Mirror the same directory structure as GitHub's go-versions repository | ||
| 2. Host the pre-built Go distribution archives | ||
| 3. Be accessible from your runners |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding a note about the manifest URL requirement. The action still fetches the versions manifest from https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json (line 17 in installer.ts), which may not be accessible in restricted environments. Users may need to configure their proxy/mirror to also handle this manifest URL or ensure it's accessible through their network configuration.
| 3. Be accessible from your runners | |
| 3. Be accessible from your runners | |
| 4. Ensure that the versions manifest file (`https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json`) is accessible from your runners. | |
| - **Note:** The action always fetches the manifest from this public URL, even when using a custom download site. In restricted environments, you may need to mirror or proxy this manifest file, or configure your network to allow access. |
| const auth = !token ? undefined : `token ${token}`; | ||
|
|
||
| const checkLatest = core.getBooleanInput('check-latest'); | ||
| const goDownloadSite = core.getInput('go-download-site') || 'https://github.com'; |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The fallback || 'https://github.com' is redundant since go-download-site has a default value in action.yml. The core.getInput() will return the default value from action.yml if not explicitly provided by the user. While this defensive approach doesn't cause issues, it could be simplified to just:
const goDownloadSite = core.getInput('go-download-site');This makes the code cleaner and relies on the single source of truth for the default value in action.yml.
| const goDownloadSite = core.getInput('go-download-site') || 'https://github.com'; | |
| const goDownloadSite = core.getInput('go-download-site'); |
This adds a new
go-download-siteinput parameter that allows users to specify a custom base URL for downloading Go distributions. This is particularly useful for GitHub Enterprise Server (GHES) environments, corporate proxies, or air-gapped setups where direct access to github.com is restricted.Changes:
go-download-siteinput toaction.yml(default:https://github.com)installer.tsto replace the default GitHub URL with the provided custom site URLmain.tsto pass the input to the installerREADME.mdwith examples for Artifactory and GHES proxiesResolves #296
Description:
Describe your changes.
Related issue:
Add link to the related issue.
Check list: