@@ -4631,6 +4631,7 @@ const core = __importStar(__webpack_require__(470));
46314631const installer = __importStar(__webpack_require__(749));
46324632const auth = __importStar(__webpack_require__(202));
46334633const path = __importStar(__webpack_require__(622));
4634+ const url_1 = __webpack_require__(835);
46344635function run() {
46354636 return __awaiter(this, void 0, void 0, function* () {
46364637 try {
@@ -4644,7 +4645,7 @@ function run() {
46444645 }
46454646 console.log(`version: ${version}`);
46464647 if (version) {
4647- let token = core.getInput('token');
4648+ let token = isGhes() ? undefined : core.getInput('token');
46484649 let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
46494650 yield installer.getNode(version, stable, token);
46504651 }
@@ -4664,6 +4665,10 @@ function run() {
46644665 });
46654666}
46664667exports.run = run;
4668+ function isGhes() {
4669+ const ghUrl = new url_1.URL(process.env['GITHUB_URL'] || 'https://github.com');
4670+ return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
4671+ }
46674672//# sourceMappingURL=main.js.map
46684673
46694674/***/ }),
@@ -12981,7 +12986,6 @@ function getNode(versionSpec, stable, token) {
1298112986 let osPlat = os.platform();
1298212987 let osArch = translateArchToDistUrl(os.arch());
1298312988 // check cache
12984- let info = null;
1298512989 let toolPath;
1298612990 toolPath = tc.find('node', versionSpec);
1298712991 // If not found in cache, download
@@ -12990,31 +12994,57 @@ function getNode(versionSpec, stable, token) {
1299012994 }
1299112995 else {
1299212996 console.log(`Attempting to download ${versionSpec}...`);
12993- let info = yield getInfoFromManifest(versionSpec, stable, token);
12994- if (!info) {
12995- console.log('Not found in manifest. Falling back to download directly from Node');
12996- info = yield getInfoFromDist(versionSpec);
12997- }
12998- if (!info) {
12999- throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
13000- }
13001- console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
1300212997 let downloadPath = '';
12998+ let info = null;
12999+ //
13000+ // Try download from internal distribution (popular versions only)
13001+ //
1300313002 try {
13004- downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, token);
13003+ info = yield getInfoFromManifest(versionSpec, stable, token);
13004+ if (info) {
13005+ console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13006+ downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, token);
13007+ }
13008+ else {
13009+ console.log('Not found in manifest. Falling back to download directly from Node');
13010+ }
1300513011 }
1300613012 catch (err) {
13007- if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
13008- yield acquireNodeFromFallbackLocation(info.resolvedVersion);
13009- return;
13013+ // Rate limited?
13014+ if (err instanceof tc.HTTPError && err.httpStatusCode === 403) {
13015+ console.log('Received HTTP status code 403. This usually indicates the rate limit has been exceeded');
13016+ }
13017+ else {
13018+ console.log(err.message);
13019+ }
13020+ core.debug(err.stack);
13021+ console.log('Falling back to download directly from Node');
13022+ }
13023+ //
13024+ // Download from nodejs.org
13025+ //
13026+ if (!downloadPath) {
13027+ info = yield getInfoFromDist(versionSpec);
13028+ if (!info) {
13029+ throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
13030+ }
13031+ console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
13032+ try {
13033+ downloadPath = yield tc.downloadTool(info.downloadUrl);
13034+ }
13035+ catch (err) {
13036+ if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
13037+ return yield acquireNodeFromFallbackLocation(info.resolvedVersion);
13038+ }
13039+ throw err;
1301013040 }
13011- throw err;
1301213041 }
1301313042 //
1301413043 // Extract
1301513044 //
1301613045 console.log('Extracting ...');
1301713046 let extPath;
13047+ info = info || {}; // satisfy compiler, never null when reaches here
1301813048 if (osPlat == 'win32') {
1301913049 let _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe');
1302013050 extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
@@ -13055,15 +13085,14 @@ exports.getNode = getNode;
1305513085function getInfoFromManifest(versionSpec, stable, token) {
1305613086 return __awaiter(this, void 0, void 0, function* () {
1305713087 let info = null;
13058- const releases = yield tc.getManifestFromRepo('actions', 'node-versions', token);
13088+ const releases = yield tc.getManifestFromRepo('actions', 'node-versions', token || '' );
1305913089 console.log(`matching ${versionSpec}...`);
1306013090 const rel = yield tc.findFromManifest(versionSpec, stable, releases);
1306113091 if (rel && rel.files.length > 0) {
1306213092 info = {};
1306313093 info.resolvedVersion = rel.version;
1306413094 info.downloadUrl = rel.files[0].download_url;
1306513095 info.fileName = rel.files[0].filename;
13066- info.token = token;
1306713096 }
1306813097 return info;
1306913098 });
@@ -13072,7 +13101,6 @@ function getInfoFromDist(versionSpec) {
1307213101 return __awaiter(this, void 0, void 0, function* () {
1307313102 let osPlat = os.platform();
1307413103 let osArch = translateArchToDistUrl(os.arch());
13075- let info = null;
1307613104 let version;
1307713105 version = yield queryDistForMatch(versionSpec);
1307813106 if (!version) {
0 commit comments