Skip to content

Commit

Permalink
Remove configuration option and automatically use the right value
Browse files Browse the repository at this point in the history
  • Loading branch information
juxtin authored Sep 27, 2024
1 parent 2857c71 commit 32b6a8b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
3 changes: 0 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 8 additions & 6 deletions componentDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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});
Expand Down
13 changes: 7 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit 32b6a8b

Please sign in to comment.