support ghes

This commit is contained in:
eric sciple
2020-05-15 14:43:02 -04:00
parent 2ae9264901
commit e37249e03d
5 changed files with 481 additions and 72 deletions

View File

@@ -2,6 +2,7 @@ import * as core from '@actions/core';
import * as installer from './installer';
import * as auth from './authutil';
import * as path from 'path';
import {URL} from 'url';
export async function run() {
try {
@@ -17,8 +18,9 @@ export async function run() {
console.log(`version: ${version}`);
if (version) {
let token = core.getInput('token');
let auth = !token || isGhes() ? undefined : `token ${token}`;
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
await installer.getNode(version, stable, token);
await installer.getNode(version, stable, auth);
}
const registryUrl: string = core.getInput('registry-url');
@@ -39,3 +41,10 @@ export async function run() {
core.setFailed(error.message);
}
}
function isGhes(): boolean {
const ghUrl = new URL(
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
);
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
}