Merge branch 'main' into update-workflows

This commit is contained in:
Priya Gupta 2024-12-18 12:32:33 +05:30 committed by GitHub
commit 517fc6ce7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 9 deletions

View File

@ -81174,11 +81174,14 @@ function isCacheFeatureAvailable() {
exports.isCacheFeatureAvailable = isCacheFeatureAvailable; exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
/** /**
* Returns this action runs on GitHub Enterprise Server or not. * Returns this action runs on GitHub Enterprise Server or not.
* (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
*/ */
function isGhes() { function isGhes() {
const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com'; const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
} }

9
dist/setup/index.js vendored
View File

@ -93633,11 +93633,14 @@ function isCacheFeatureAvailable() {
exports.isCacheFeatureAvailable = isCacheFeatureAvailable; exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
/** /**
* Returns this action runs on GitHub Enterprise Server or not. * Returns this action runs on GitHub Enterprise Server or not.
* (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
*/ */
function isGhes() { function isGhes() {
const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com'; const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
} }

View File

@ -90,9 +90,16 @@ export function isCacheFeatureAvailable(): boolean {
/** /**
* Returns this action runs on GitHub Enterprise Server or not. * Returns this action runs on GitHub Enterprise Server or not.
* (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
*/ */
function isGhes(): boolean { function isGhes(): boolean {
const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com'; const ghUrl = new URL(
return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM'; process.env['GITHUB_SERVER_URL'] || 'https://github.com'
);
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
} }