Skip to content

Commit 8511b07

Browse files
committed
Create fix for Add GitHub Enterprise Server support #42
1 parent 7303e5e commit 8511b07

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ 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. By default, this is github.com/api/v3, but it can be set to your GitHub Enterprise Server instead.'
26+
required: false
27+
default: 'https://github.com/api/v3'
2428
runs:
2529
using: 'node16'
2630
main: 'dist/index.js'

componentDetection.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,13 @@ export default class ComponentDetection {
140140
}
141141

142142
private static async getLatestReleaseURL(): Promise<string> {
143-
const githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
144-
const octokit = github.getOctokit(githubToken);
143+
var githubToken = core.getInput('token') || process.env.GITHUB_TOKEN || "";
144+
145+
// If the releaseServerUrl is github.com and Actions environment is GHES, then use an empty string as the token
146+
if (core.getInput('releaseServerUrl') != github.context.apiUrl) {
147+
githubToken = "";
148+
}
149+
const octokit = github.getOctokit(githubToken, { baseUrl: core.getInput('releaseServerUrl') });
145150
const owner = "microsoft";
146151
const repo = "component-detection";
147152

0 commit comments

Comments
 (0)