feat: support private mirrors (#1240)

* feat: support private mirrors

* chore: change fallback message with mirrors
This commit is contained in:
Marco Ippolito
2025-04-02 17:49:47 +02:00
committed by GitHub
parent 40337cb8f7
commit e3ce749e20
14 changed files with 322 additions and 44 deletions

View File

@ -84,7 +84,7 @@ export default class OfficialBuilds extends BaseDistribution {
downloadPath = await tc.downloadTool(
versionInfo.downloadUrl,
undefined,
this.nodeInfo.auth
this.nodeInfo.mirror ? this.nodeInfo.mirrorToken : this.nodeInfo.auth
);
if (downloadPath) {
@ -96,7 +96,9 @@ export default class OfficialBuilds extends BaseDistribution {
}
} else {
core.info(
'Not found in manifest. Falling back to download directly from Node'
`Not found in manifest. Falling back to download directly from ${
this.nodeInfo.mirror || 'Node'
}`
);
}
} catch (err) {
@ -176,8 +178,9 @@ export default class OfficialBuilds extends BaseDistribution {
return version;
}
protected getDistributionUrl(): string {
return `https://nodejs.org/dist`;
protected getDistributionUrl(mirror: string): string {
const url = mirror || 'https://nodejs.org';
return `${url}/dist`;
}
private getManifest(): Promise<tc.IToolRelease[]> {
@ -185,7 +188,7 @@ export default class OfficialBuilds extends BaseDistribution {
return tc.getManifestFromRepo(
'actions',
'node-versions',
this.nodeInfo.auth,
this.nodeInfo.mirror ? this.nodeInfo.mirrorToken : this.nodeInfo.auth,
'main'
);
}