Skip to content

Commit 32b6a8b

Browse files
authored
Remove configuration option and automatically use the right value
1 parent 2857c71 commit 32b6a8b

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ inputs:
2121
detectorsFilter:
2222
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.'
2323
required: false
24-
releaseServerUrl:
25-
description: 'The baseUrl of the release server to use. If you set this, it should be set to `https://api.github.com`'
26-
required: false
2724
runs:
2825
using: 'node16'
2926
main: 'dist/index.js'

componentDetection.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,16 @@ export default class ComponentDetection {
141141
}
142142

143143
private static async getLatestReleaseURL(): Promise<string> {
144-
var githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
144+
let githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
145145

146-
// If the releaseServerUrl is set, then use an empty string as the token
147-
if (core.getInput('releaseServerUrl') != null) {
146+
const githubAPIURL = 'https://api.github.com'
147+
148+
let ghesMode = github.context.apiUrl != githubAPIURL;
149+
// If the we're running in GHES, then use an empty string as the token
150+
if (ghesMode) {
148151
githubToken = "";
149152
}
150-
const serverUrl = core.getInput('releaseServerUrl') || github.context.apiUrl;
151-
const octokit = new Octokit({ auth: githubToken, baseUrl: serverUrl, request: { fetch: fetch}, log: {
153+
const octokit = new Octokit({ auth: githubToken, baseUrl: githubAPIURL, request: { fetch: fetch}, log: {
152154
debug: core.debug,
153155
info: core.info,
154156
warn: core.warning,
@@ -157,7 +159,7 @@ export default class ComponentDetection {
157159

158160
const owner = "microsoft";
159161
const repo = "component-detection";
160-
core.debug("Attempting to download latest release from " + serverUrl);
162+
core.debug("Attempting to download latest release from " + githubAPIURL);
161163

162164
try {
163165
const latestRelease = await octokit.request("GET /repos/{owner}/{repo}/releases/latest", {owner, repo});

dist/index.js

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)