mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-06 02:43:19 +08:00
Added cacheSize in ReserveCache API request
This commit is contained in:
13
packages/cache/src/internal/cacheHttpClient.ts
vendored
13
packages/cache/src/internal/cacheHttpClient.ts
vendored
@@ -31,7 +31,12 @@ import {
|
||||
const versionSalt = '1.0'
|
||||
|
||||
function getCacheApiUrl(resource: string): string {
|
||||
const baseUrl: string = process.env['ACTIONS_CACHE_URL'] || ''
|
||||
// Ideally we just use ACTIONS_CACHE_URL
|
||||
const baseUrl: string = (
|
||||
process.env['ACTIONS_CACHE_URL'] ||
|
||||
process.env['ACTIONS_RUNTIME_URL'] ||
|
||||
''
|
||||
).replace('pipelines', 'artifactcache')
|
||||
if (!baseUrl) {
|
||||
throw new Error('Cache Service Url not found, unable to restore cache.')
|
||||
}
|
||||
@@ -149,7 +154,8 @@ export async function reserveCache(
|
||||
|
||||
const reserveCacheRequest: ReserveCacheRequest = {
|
||||
key,
|
||||
version
|
||||
version,
|
||||
cacheSize: options?.cacheSize
|
||||
}
|
||||
const response = await retryTypedResponse('reserveCache', async () =>
|
||||
httpClient.postJson<ReserveCacheResponse>(
|
||||
@@ -157,6 +163,9 @@ export async function reserveCache(
|
||||
reserveCacheRequest
|
||||
)
|
||||
)
|
||||
if(response?.statusCode === 400){
|
||||
return -2
|
||||
}
|
||||
return response?.result?.cacheId ?? -1
|
||||
}
|
||||
|
||||
|
||||
7
packages/cache/src/internal/cacheUtils.ts
vendored
7
packages/cache/src/internal/cacheUtils.ts
vendored
@@ -123,3 +123,10 @@ 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"
|
||||
);
|
||||
return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
|
||||
}
|
||||
|
||||
2
packages/cache/src/internal/contracts.d.ts
vendored
2
packages/cache/src/internal/contracts.d.ts
vendored
@@ -14,6 +14,7 @@ export interface CommitCacheRequest {
|
||||
export interface ReserveCacheRequest {
|
||||
key: string
|
||||
version?: string
|
||||
cacheSize?: number
|
||||
}
|
||||
|
||||
export interface ReserveCacheResponse {
|
||||
@@ -22,4 +23,5 @@ export interface ReserveCacheResponse {
|
||||
|
||||
export interface InternalCacheOptions {
|
||||
compressionMethod?: CompressionMethod
|
||||
cacheSize?: number
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user