diff --git a/action.yml b/action.yml index 04579e4c2..6ca8a0c30 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,12 @@ inputs: custom-server-id: description: "Custom JFrog CLI configuration server ID to use instead of the default one generated by the action." required: false + ghe-base-url: + description: 'Base URL GitHub Enterprise Server REST API.' + required: false + ghe_base_url: + description: 'Alias for ghe-base-url' + required: false outputs: oidc-token: description: "JFrog OIDC token generated by the Setup JFrog CLI when setting oidc-provider-name." diff --git a/lib/job-summary.js b/lib/job-summary.js index 564465922..b1d0b7d61 100644 --- a/lib/job-summary.js +++ b/lib/job-summary.js @@ -118,7 +118,7 @@ class JobSummary { static uploadCodeScanningSarif(encodedSarif, token) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c; - const inputBaseUrl = core.getInput('ghe-base-url', { required: false }) || core.getInput('ghe_base_url', { required: false }) || ''; + const inputBaseUrl = utils_1.Utils.getGheBaseUrl(); const octokit = inputBaseUrl ? github.getOctokit(token, { baseUrl: inputBaseUrl }) : github.getOctokit(token); const response = yield octokit.request('POST /repos/{owner}/{repo}/code-scanning/sarifs', { owner: github.context.repo.owner, diff --git a/lib/utils.js b/lib/utils.js index 7ee12f4cc..c5c6c42a7 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -73,6 +73,10 @@ class Utils { } return jfrogCredentials; } + static getGheBaseUrl() { + const v = core.getInput(Utils.GHE_BASE_URL_INPUT, { required: false }) || core.getInput(Utils.GHE_BASE_URL_ALIAS_INPUT, { required: false }) || ''; + return v.trim(); + } static getAndAddCliToPath(jfrogCredentials) { return __awaiter(this, void 0, void 0, function* () { let version = core.getInput(Utils.CLI_VERSION_ARG); @@ -489,3 +493,6 @@ Utils.AUTO_BUILD_PUBLISH_DISABLE = 'disable-auto-build-publish'; Utils.AUTO_EVIDENCE_COLLECTION_DISABLE = 'disable-auto-evidence-collection'; // Custom server ID input Utils.CUSTOM_SERVER_ID = 'custom-server-id'; +// GHES baseUrl support +Utils.GHE_BASE_URL_INPUT = 'ghe-base-url'; +Utils.GHE_BASE_URL_ALIAS_INPUT = 'ghe_base_url'; diff --git a/src/job-summary.ts b/src/job-summary.ts index 8206446dc..9dd744aa2 100644 --- a/src/job-summary.ts +++ b/src/job-summary.ts @@ -115,7 +115,7 @@ export class JobSummary { * @throws Will throw an error if the HTTP response status is not in the 2xx range or if authentication fails. */ private static async uploadCodeScanningSarif(encodedSarif: string, token: string) { - const inputBaseUrl = core.getInput('ghe-base-url', { required: false }) || core.getInput('ghe_base_url', { required: false }) || ''; + const inputBaseUrl = Utils.getGheBaseUrl(); const octokit = inputBaseUrl ? github.getOctokit(token, { baseUrl: inputBaseUrl }) : github.getOctokit(token); diff --git a/src/utils.ts b/src/utils.ts index b1f013552..91d2212ca 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -54,6 +54,9 @@ export class Utils { public static readonly AUTO_EVIDENCE_COLLECTION_DISABLE: string = 'disable-auto-evidence-collection'; // Custom server ID input private static readonly CUSTOM_SERVER_ID: string = 'custom-server-id'; + // GHES baseUrl support + public static readonly GHE_BASE_URL_INPUT: string = 'ghe-base-url'; + public static readonly GHE_BASE_URL_ALIAS_INPUT: string = 'ghe_base_url'; /** * Gathers JFrog's credentials from environment variables and delivers them in a JfrogCredentials structure @@ -88,6 +91,12 @@ export class Utils { return jfrogCredentials; } + public static getGheBaseUrl(): string { + const v = + core.getInput(Utils.GHE_BASE_URL_INPUT, { required: false }) || core.getInput(Utils.GHE_BASE_URL_ALIAS_INPUT, { required: false }) || ''; + return v.trim(); + } + public static async getAndAddCliToPath(jfrogCredentials: JfrogCredentials) { let version: string = core.getInput(Utils.CLI_VERSION_ARG); let cliRemote: string = core.getInput(Utils.CLI_REMOTE_ARG);