Skip to content

Conversation

@abdennour
Copy link

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 #296

Description:
Describe your changes.

Related issue:
Add link to the related issue.

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

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
@abdennour abdennour requested a review from a team as a code owner November 29, 2025 20:49
Copilot AI review requested due to automatic review settings November 29, 2025 20:49
Copilot finished reviewing on behalf of abdennour November 29, 2025 20:52
Copy link

Copilot AI left a 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-site input parameter with default value https://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
```
Copy link

Copilot AI Nov 29, 2025

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."

Suggested change
**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.

Copilot uses AI. Check for mistakes.
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);
Copy link

Copilot AI Nov 29, 2025

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:

  1. 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.

  2. No trailing slash handling: If goDownloadSite ends 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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
- 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.
Copy link

Copilot AI Nov 29, 2025

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:

  1. The parameter only affects downloads from the go-versions repository manifest
  2. When manifest downloads fail, the action falls back to go.dev without using the custom download site
  3. 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.

Suggested change
> **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.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Nov 29, 2025

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
const auth = !token ? undefined : `token ${token}`;

const checkLatest = core.getBooleanInput('check-latest');
const goDownloadSite = core.getInput('go-download-site') || 'https://github.com';
Copy link

Copilot AI Nov 29, 2025

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.

Suggested change
const goDownloadSite = core.getInput('go-download-site') || 'https://github.com';
const goDownloadSite = core.getInput('go-download-site');

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to proxy the files from versions-manifest.json

1 participant