Remove configuration option and automatically use the right value

This commit is contained in:
Justin Holguín
2024-09-27 21:47:54 +00:00
committed by GitHub
parent 2857c71253
commit 32b6a8be43
4 changed files with 16 additions and 16 deletions
-3
View File
@@ -21,9 +21,6 @@ inputs:
detectorsFilter:
description: 'A comma separated list with the identifiers of the specific detectors to be used. This is meant to be used for testing purposes only.'
required: false
releaseServerUrl:
description: 'The baseUrl of the release server to use. If you set this, it should be set to `https://api.github.com`'
required: false
runs:
using: 'node16'
main: 'dist/index.js'
+8 -6
View File
@@ -141,14 +141,16 @@ export default class ComponentDetection {
}
private static async getLatestReleaseURL(): Promise<string> {
var githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
let githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
// If the releaseServerUrl is set, then use an empty string as the token
if (core.getInput('releaseServerUrl') != null) {
const githubAPIURL = 'https://api.github.com'
let ghesMode = github.context.apiUrl != githubAPIURL;
// If the we're running in GHES, then use an empty string as the token
if (ghesMode) {
githubToken = "";
}
const serverUrl = core.getInput('releaseServerUrl') || github.context.apiUrl;
const octokit = new Octokit({ auth: githubToken, baseUrl: serverUrl, request: { fetch: fetch}, log: {
const octokit = new Octokit({ auth: githubToken, baseUrl: githubAPIURL, request: { fetch: fetch}, log: {
debug: core.debug,
info: core.info,
warn: core.warning,
@@ -157,7 +159,7 @@ export default class ComponentDetection {
const owner = "microsoft";
const repo = "component-detection";
core.debug("Attempting to download latest release from " + serverUrl);
core.debug("Attempting to download latest release from " + githubAPIURL);
try {
const latestRelease = await octokit.request("GET /repos/{owner}/{repo}/releases/latest", {owner, repo});
Generated Vendored
+7 -6
View File
@@ -24968,13 +24968,14 @@ class ComponentDetection {
}
static getLatestReleaseURL() {
return __awaiter(this, void 0, void 0, function* () {
var githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
// If the releaseServerUrl is set, then use an empty string as the token
if (core.getInput('releaseServerUrl') != null) {
let githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
const githubAPIURL = 'https://api.github.com';
let ghesMode = github.context.apiUrl != githubAPIURL;
// If the we're running in GHES, then use an empty string as the token
if (ghesMode) {
githubToken = "";
}
const serverUrl = core.getInput('releaseServerUrl') || github.context.apiUrl;
const octokit = new octokit_1.Octokit({ auth: githubToken, baseUrl: serverUrl, request: { fetch: cross_fetch_1.default }, log: {
const octokit = new octokit_1.Octokit({ auth: githubToken, baseUrl: githubAPIURL, request: { fetch: cross_fetch_1.default }, log: {
debug: core.debug,
info: core.info,
warn: core.warning,
@@ -24982,7 +24983,7 @@ class ComponentDetection {
}, });
const owner = "microsoft";
const repo = "component-detection";
core.debug("Attempting to download latest release from " + serverUrl);
core.debug("Attempting to download latest release from " + githubAPIURL);
try {
const latestRelease = yield octokit.request("GET /repos/{owner}/{repo}/releases/latest", { owner, repo });
var downloadURL = "";
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long