Skip to content

Commit c026f3a

Browse files
MishaKavclaude
andauthored
Add server-url option for self-hosted GitHub instances (#234)
Implemented automatic server URL detection to support self-hosted GitHub instances, matching the jest-coverage-comment implementation exactly. - serverUrl is automatically calculated from context.serverUrl - Falls back to 'https://github.com' for standard GitHub - Updated repoUrl construction to use serverUrl for file links - Added logging to show which GitHub URL is being used This allows users running GitHub Enterprise Server or other self-hosted GitHub instances to have coverage report links point to the correct server automatically, without requiring any additional configuration. Co-authored-by: Claude <noreply@anthropic.com>
1 parent 10c84f1 commit c026f3a

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

dist/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39505,6 +39505,9 @@ const main = async () => {
3950539505
const { context, repository } = github;
3950639506
const { repo, owner } = context.repo;
3950739507
const { eventName, payload } = context;
39508+
const serverUrl = context.serverUrl || 'https://github.com';
39509+
39510+
core.info(`Uses Github URL: ${serverUrl}`);
3950839511
const watermarkUniqueId = uniqueIdForComment
3950939512
? `| ${uniqueIdForComment} `
3951039513
: '';
@@ -39536,7 +39539,7 @@ const main = async () => {
3953639539
};
3953739540

3953839541
options.repoUrl =
39539-
payload.repository?.html_url || `https://github.com/${options.repository}`;
39542+
payload.repository?.html_url || `${serverUrl}/${options.repository}`;
3954039543

3954139544
// Initialize octokit early so we can use it for tag resolution
3954239545
const octokit = github.getOctokit(token);

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ const main = async () => {
198198
const { context, repository } = github;
199199
const { repo, owner } = context.repo;
200200
const { eventName, payload } = context;
201+
const serverUrl = context.serverUrl || 'https://github.com';
202+
203+
core.info(`Uses Github URL: ${serverUrl}`);
201204
const watermarkUniqueId = uniqueIdForComment
202205
? `| ${uniqueIdForComment} `
203206
: '';
@@ -229,7 +232,7 @@ const main = async () => {
229232
};
230233

231234
options.repoUrl =
232-
payload.repository?.html_url || `https://github.com/${options.repository}`;
235+
payload.repository?.html_url || `${serverUrl}/${options.repository}`;
233236

234237
// Initialize octokit early so we can use it for tag resolution
235238
const octokit = github.getOctokit(token);

0 commit comments

Comments
 (0)