From ea267efe868351c420ee72d68d6e5233eabe587d Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Thu, 10 Aug 2023 06:17:07 +0200 Subject: [PATCH] Add isGhes utility --- packages/core/src/core.ts | 5 +++++ packages/core/src/utils.ts | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 1e8d940a..f33b7d86 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -386,3 +386,8 @@ export {markdownSummary} from './summary' * Path exports */ export {toPosixPath, toWin32Path, toPlatformPath} from './path-utils' + +/** + * isGhes helper export + */ +export {isGhes} from './utils' diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index c43f3870..eb7825f5 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -39,3 +39,11 @@ export function toCommandProperties( endColumn: annotationProperties.endColumn } } + +/** + * Returns this action runs on GitHub Enterprise Server or not. + */ +export function isGhes(): boolean { + const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com' + return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM' +}