Add v2 cache upload

This commit is contained in:
Bassem Dghaidi
2024-06-10 10:56:20 -07:00
committed by GitHub
parent c8466d1fac
commit 66d5434f23
2 changed files with 37 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
import * as core from '@actions/core'
import {GetCacheBlobUploadURLResponse} from '../../../generated/results/api/v1/blobcache'
import {BlobClient, BlockBlobParallelUploadOptions} from '@azure/storage-blob'
export async function UploadCache(
uploadURL: GetCacheBlobUploadURLResponse,
archivePath: string,
): Promise<{}> {
core.debug(`Uploading cache to: ${uploadURL}`)
// Specify data transfer options
const uploadOptions: BlockBlobParallelUploadOptions = {
blockSize: 4 * 1024 * 1024, // 4 MiB max block size
concurrency: 2, // maximum number of parallel transfer workers
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
};
// Create blob client from container client
const blobClient: BlobClient = new BlobClient(uploadURL.urls[0])
return blobClient.uploadFile(archivePath, uploadOptions);
}