From 56bae6ff07fae4484f4171d5823db10668fff9cd Mon Sep 17 00:00:00 2001 From: Nikhil Mittal Date: Thu, 25 Jun 2026 12:31:18 +0530 Subject: [PATCH 1/2] fix: use github.context.serverUrl instead of hardcoded URL for GHES support (#2052) --- __tests__/dependencies.test.ts | 51 +++++++++++++++++++++++++++++++++- src/dependencies.ts | 5 ++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/__tests__/dependencies.test.ts b/__tests__/dependencies.test.ts index f29c512..ea0c76b 100644 --- a/__tests__/dependencies.test.ts +++ b/__tests__/dependencies.test.ts @@ -20,7 +20,8 @@ jest.mock('@actions/github', () => ({ }, runId: 12345, runAttempt: 1, - job: 'test-job' + job: 'test-job', + serverUrl: 'https://github.com' }, getOctokit: jest.fn() })) @@ -304,6 +305,54 @@ describe('RuntimeDependencies Code Coverage', () => { expect(result).toEqual('https://github.com/test-owner/test-repo/actions/runs/12345/attempts/1') }) + it('createActionSummaryLink - uses serverUrl for GitHub Enterprise Server', async () => { + const originalServerUrl = github.context.serverUrl + ;(github.context as { serverUrl: string }).serverUrl = 'https://github.securian.com' + + const mockOctokit = { + rest: { + actions: { + listJobsForWorkflowRun: jest.fn().mockResolvedValue({ + data: { + jobs: [{ id: 5, name: 'test-job' }] + } + }) + } + } + } + ;(github.getOctokit as jest.Mock).mockReturnValue(mockOctokit) + + const result = await dependencies.createActionSummaryLink('test-token') + + expect(result).toEqual( + 'https://github.securian.com/test-owner/test-repo/actions/runs/12345/attempts/1#summary-5' + ) + ;(github.context as { serverUrl: string }).serverUrl = originalServerUrl + }) + + it('createActionSummaryLink - uses serverUrl for GHES without matching job', async () => { + const originalServerUrl = github.context.serverUrl + ;(github.context as { serverUrl: string }).serverUrl = 'https://github.securian.com' + + const mockOctokit = { + rest: { + actions: { + listJobsForWorkflowRun: jest.fn().mockResolvedValue({ + data: { + jobs: [{ id: 1, name: 'other-job' }] + } + }) + } + } + } + ;(github.getOctokit as jest.Mock).mockReturnValue(mockOctokit) + + const result = await dependencies.createActionSummaryLink('test-token') + + expect(result).toEqual('https://github.securian.com/test-owner/test-repo/actions/runs/12345/attempts/1') + ;(github.context as { serverUrl: string }).serverUrl = originalServerUrl + }) + it('createActionSummaryLink - API error', async () => { const mockOctokit = { rest: { diff --git a/src/dependencies.ts b/src/dependencies.ts index 97898d1..f24470f 100644 --- a/src/dependencies.ts +++ b/src/dependencies.ts @@ -108,6 +108,7 @@ export class RuntimeDependencies implements Dependencies { const repo = github.context.repo.repo const runId = github.context.runId const runAttempt = github.context.runAttempt + const serverUrl = github.context.serverUrl const octokit = github.getOctokit(githubToken) let matchingJob: { id: number } | undefined try { @@ -128,9 +129,9 @@ export class RuntimeDependencies implements Dependencies { // matrices, then we can't link directly to the table, and have to link to just the page itself and expect the user] // to scroll down the table themselves. if (matchingJob) { - return `https://github.com/${owner}/${repo}/actions/runs/${runId}/attempts/${runAttempt}#summary-${matchingJob.id}` + return `${serverUrl}/${owner}/${repo}/actions/runs/${runId}/attempts/${runAttempt}#summary-${matchingJob.id}` } else { - return `https://github.com/${owner}/${repo}/actions/runs/${runId}/attempts/${runAttempt}` + return `${serverUrl}/${owner}/${repo}/actions/runs/${runId}/attempts/${runAttempt}` } } From 06834ad15551ce7a8312ad9358c084e61dc97d9c Mon Sep 17 00:00:00 2001 From: Nikhil Mittal Date: Thu, 25 Jun 2026 12:44:55 +0530 Subject: [PATCH 2/2] update PR --- dist/index.js | 5 +++-- package-lock.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4434a38..9202367 100644 --- a/dist/index.js +++ b/dist/index.js @@ -106132,6 +106132,7 @@ class RuntimeDependencies { const repo = github.context.repo.repo; const runId = github.context.runId; const runAttempt = github.context.runAttempt; + const serverUrl = github.context.serverUrl; const octokit = github.getOctokit(githubToken); let matchingJob; try { @@ -106153,10 +106154,10 @@ class RuntimeDependencies { // matrices, then we can't link directly to the table, and have to link to just the page itself and expect the user] // to scroll down the table themselves. if (matchingJob) { - return `https://github.com/${owner}/${repo}/actions/runs/${runId}/attempts/${runAttempt}#summary-${matchingJob.id}`; + return `${serverUrl}/${owner}/${repo}/actions/runs/${runId}/attempts/${runAttempt}#summary-${matchingJob.id}`; } else { - return `https://github.com/${owner}/${repo}/actions/runs/${runId}/attempts/${runAttempt}`; + return `${serverUrl}/${owner}/${repo}/actions/runs/${runId}/attempts/${runAttempt}`; } } async createPullRequestReview(githubToken, reviewBody) { diff --git a/package-lock.json b/package-lock.json index 8d412af..12d7c31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "typescript-eslint": "^8.59.4" }, "engines": { - "node": ">=20.9.0" + "node": ">=24.0.0" } }, "node_modules/@actions/artifact": {