mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-06 19:43:23 +08:00
Add isGhes gate and refactor to clean up circular dependencies
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
BlobDownloadOptions
|
||||
} from '@azure/storage-blob'
|
||||
|
||||
export async function DownloadCacheFile(
|
||||
export async function downloadCacheFile(
|
||||
signedUploadURL: string,
|
||||
archivePath: string
|
||||
): Promise<{}> {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
BlockBlobParallelUploadOptions
|
||||
} from '@azure/storage-blob'
|
||||
|
||||
export async function UploadCacheFile(
|
||||
export async function uploadCacheFile(
|
||||
signedUploadURL: string,
|
||||
archivePath: string
|
||||
): Promise<{}> {
|
||||
|
||||
13
packages/cache/src/internal/cacheUtils.ts
vendored
13
packages/cache/src/internal/cacheUtils.ts
vendored
@@ -133,19 +133,6 @@ export function assertDefined<T>(name: string, value?: T): T {
|
||||
return value
|
||||
}
|
||||
|
||||
export function isGhes(): boolean {
|
||||
const ghUrl = new URL(
|
||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||
)
|
||||
|
||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
||||
const isGitHubHost = hostname === 'GITHUB.COM'
|
||||
const isGheHost =
|
||||
hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST')
|
||||
|
||||
return !isGitHubHost && !isGheHost
|
||||
}
|
||||
|
||||
export function getCacheVersion(
|
||||
paths: string[],
|
||||
compressionMethod?: CompressionMethod,
|
||||
|
||||
20
packages/cache/src/internal/config.ts
vendored
20
packages/cache/src/internal/config.ts
vendored
@@ -1,9 +1,29 @@
|
||||
export function isGhes(): boolean {
|
||||
const ghUrl = new URL(
|
||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||
)
|
||||
|
||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
||||
const isGitHubHost = hostname === 'GITHUB.COM'
|
||||
const isGheHost = hostname.endsWith('.GHE.COM')
|
||||
const isLocalHost = hostname.endsWith('.LOCALHOST')
|
||||
|
||||
return !isGitHubHost && !isGheHost && !isLocalHost
|
||||
}
|
||||
|
||||
export function getCacheServiceVersion(): string {
|
||||
// Cache service v2 is not supported on GHES. We will default to
|
||||
// cache service v1 even if the feature flag was enabled by user.
|
||||
if (isGhes()) return 'v1'
|
||||
|
||||
return process.env['ACTIONS_CACHE_SERVICE_V2'] ? 'v2' : 'v1'
|
||||
}
|
||||
|
||||
export function getCacheServiceURL(): string {
|
||||
const version = getCacheServiceVersion()
|
||||
|
||||
// Based on the version of the cache service, we will determine which
|
||||
// URL to use.
|
||||
switch (version) {
|
||||
case 'v1':
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user