Skip to content

Commit 39e9b76

Browse files
authored
Fix/ghes sarif baseurl - action.yml declaration; Centralized reading of input from utils as per style (#301)
* feat(ghes): add ghe-base-url input and honor baseUrl for Octokit when uploading SARIF * Revert "feat(ghes): add ghe-base-url input and honor baseUrl for Octokit when uploading SARIF" This reverts commit e62277a. * feat(ghes): add ghe-base-url input and honor baseUrl for SARIF uploads * Action declaration; Centralized reading of input from utils as per style --------- Co-authored-by: p4r53c <[email protected]>
1 parent d814d84 commit 39e9b76

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ inputs:
3030
custom-server-id:
3131
description: "Custom JFrog CLI configuration server ID to use instead of the default one generated by the action."
3232
required: false
33+
ghe-base-url:
34+
description: 'Base URL GitHub Enterprise Server REST API.'
35+
required: false
36+
ghe_base_url:
37+
description: 'Alias for ghe-base-url'
38+
required: false
3339
outputs:
3440
oidc-token:
3541
description: "JFrog OIDC token generated by the Setup JFrog CLI when setting oidc-provider-name."

lib/job-summary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class JobSummary {
118118
static uploadCodeScanningSarif(encodedSarif, token) {
119119
return __awaiter(this, void 0, void 0, function* () {
120120
var _a, _b, _c;
121-
const inputBaseUrl = core.getInput('ghe-base-url', { required: false }) || core.getInput('ghe_base_url', { required: false }) || '';
121+
const inputBaseUrl = utils_1.Utils.getGheBaseUrl();
122122
const octokit = inputBaseUrl ? github.getOctokit(token, { baseUrl: inputBaseUrl }) : github.getOctokit(token);
123123
const response = yield octokit.request('POST /repos/{owner}/{repo}/code-scanning/sarifs', {
124124
owner: github.context.repo.owner,

lib/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class Utils {
7373
}
7474
return jfrogCredentials;
7575
}
76+
static getGheBaseUrl() {
77+
const v = core.getInput(Utils.GHE_BASE_URL_INPUT, { required: false }) || core.getInput(Utils.GHE_BASE_URL_ALIAS_INPUT, { required: false }) || '';
78+
return v.trim();
79+
}
7680
static getAndAddCliToPath(jfrogCredentials) {
7781
return __awaiter(this, void 0, void 0, function* () {
7882
let version = core.getInput(Utils.CLI_VERSION_ARG);
@@ -489,3 +493,6 @@ Utils.AUTO_BUILD_PUBLISH_DISABLE = 'disable-auto-build-publish';
489493
Utils.AUTO_EVIDENCE_COLLECTION_DISABLE = 'disable-auto-evidence-collection';
490494
// Custom server ID input
491495
Utils.CUSTOM_SERVER_ID = 'custom-server-id';
496+
// GHES baseUrl support
497+
Utils.GHE_BASE_URL_INPUT = 'ghe-base-url';
498+
Utils.GHE_BASE_URL_ALIAS_INPUT = 'ghe_base_url';

src/job-summary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class JobSummary {
115115
* @throws Will throw an error if the HTTP response status is not in the 2xx range or if authentication fails.
116116
*/
117117
private static async uploadCodeScanningSarif(encodedSarif: string, token: string) {
118-
const inputBaseUrl = core.getInput('ghe-base-url', { required: false }) || core.getInput('ghe_base_url', { required: false }) || '';
118+
const inputBaseUrl = Utils.getGheBaseUrl();
119119

120120
const octokit = inputBaseUrl ? github.getOctokit(token, { baseUrl: inputBaseUrl }) : github.getOctokit(token);
121121

src/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export class Utils {
5454
public static readonly AUTO_EVIDENCE_COLLECTION_DISABLE: string = 'disable-auto-evidence-collection';
5555
// Custom server ID input
5656
private static readonly CUSTOM_SERVER_ID: string = 'custom-server-id';
57+
// GHES baseUrl support
58+
public static readonly GHE_BASE_URL_INPUT: string = 'ghe-base-url';
59+
public static readonly GHE_BASE_URL_ALIAS_INPUT: string = 'ghe_base_url';
5760

5861
/**
5962
* Gathers JFrog's credentials from environment variables and delivers them in a JfrogCredentials structure
@@ -88,6 +91,12 @@ export class Utils {
8891
return jfrogCredentials;
8992
}
9093

94+
public static getGheBaseUrl(): string {
95+
const v =
96+
core.getInput(Utils.GHE_BASE_URL_INPUT, { required: false }) || core.getInput(Utils.GHE_BASE_URL_ALIAS_INPUT, { required: false }) || '';
97+
return v.trim();
98+
}
99+
91100
public static async getAndAddCliToPath(jfrogCredentials: JfrogCredentials) {
92101
let version: string = core.getInput(Utils.CLI_VERSION_ARG);
93102
let cliRemote: string = core.getInput(Utils.CLI_REMOTE_ARG);

0 commit comments

Comments
 (0)