mirror of https://github.com/actions/toolkit
adds explicit token auth mechanism
parent
9a8c6b26ce
commit
a09029945f
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "github-actions.warp-cache",
|
||||
"version": "0.3.0",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "github-actions.warp-cache",
|
||||
"version": "0.3.0",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
|
@ -19,6 +19,7 @@
|
|||
"@azure/storage-blob": "^12.13.0",
|
||||
"@google-cloud/storage": "^7.9.0",
|
||||
"axios": "^1.6.2",
|
||||
"google-auth-library": "^9.7.0",
|
||||
"semver": "^6.3.1",
|
||||
"uuid": "^3.3.3"
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "github-actions.warp-cache",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"preview": true,
|
||||
"description": "Github action to use WarpBuild's in-house cache offering",
|
||||
"keywords": [
|
||||
|
@ -48,6 +48,7 @@
|
|||
"@azure/storage-blob": "^12.13.0",
|
||||
"@google-cloud/storage": "^7.9.0",
|
||||
"axios": "^1.6.2",
|
||||
"google-auth-library": "^9.7.0",
|
||||
"semver": "^6.3.1",
|
||||
"uuid": "^3.3.3"
|
||||
},
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
listTar
|
||||
} from './internal/tar'
|
||||
import {DownloadOptions, getUploadOptions} from './options'
|
||||
import {isSuccessStatusCode} from './internal/requestUtils'
|
||||
|
||||
export class ValidationError extends Error {
|
||||
constructor(message: string) {
|
||||
|
@ -281,7 +282,7 @@ export async function saveCache(
|
|||
cacheVersion
|
||||
)
|
||||
|
||||
if (reserveCacheResponse?.statusCode === 400) {
|
||||
if (!isSuccessStatusCode(reserveCacheResponse?.statusCode)) {
|
||||
throw new Error(
|
||||
reserveCacheResponse?.error?.message ??
|
||||
`Cache size of ~${Math.round(
|
||||
|
|
|
@ -31,6 +31,7 @@ import {
|
|||
import {multiPartUploadToGCS, uploadFileToS3} from './uploadUtils'
|
||||
import {CommonsGetCacheRequest} from './warpcache-ts-sdk/models/commons-get-cache-request'
|
||||
import {CommonsDeleteCacheRequest} from './warpcache-ts-sdk/models/commons-delete-cache-request'
|
||||
import {OAuth2Client} from 'google-auth-library'
|
||||
|
||||
const versionSalt = '1.0'
|
||||
|
||||
|
@ -206,8 +207,10 @@ export function downloadCacheStreaming(
|
|||
'Unable to download cache from GCS. GCP token is not provided.'
|
||||
)
|
||||
}
|
||||
const oauth2Client = new OAuth2Client()
|
||||
oauth2Client.setCredentials({access_token: gcsToken})
|
||||
const storage = new Storage({
|
||||
token: gcsToken
|
||||
authClient: oauth2Client
|
||||
})
|
||||
return downloadCacheStreamingGCP(storage, archiveLocation)
|
||||
}
|
||||
|
@ -345,8 +348,10 @@ export async function saveCache(
|
|||
}
|
||||
|
||||
core.debug('Uploading cache')
|
||||
const oauth2Client = new OAuth2Client()
|
||||
oauth2Client.setCredentials({access_token: GCSAuthToken})
|
||||
const storage = new Storage({
|
||||
token: GCSAuthToken
|
||||
authClient: oauth2Client
|
||||
})
|
||||
await multiPartUploadToGCS(
|
||||
storage,
|
||||
|
|
|
@ -7,15 +7,16 @@ process.env['WARPBUILD_CACHE_URL'] = 'https://cache.dev.warpbuild.dev'
|
|||
process.env['RUNNER_TEMP'] = '/Users/prajjwal/Repos/warpbuild/playground/tmp_fs'
|
||||
process.env['NODE_DEBUG'] = 'http'
|
||||
process.env['RUNNER_DEBUG'] = '1'
|
||||
process.env['WARPBUILD_RUNNER_VERIFICATION_TOKEN'] = '<Set_token_here>'
|
||||
process.env['WARPBUILD_RUNNER_VERIFICATION_TOKEN'] =
|
||||
'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTM0MTg3MzMsInJlcG8iOiJiZW5jaG1hcmtzIiwicmVwb093bmVyIjoiV2FycEJ1aWxkcyIsIngtd2FycGJ1aWxkLW9yZ2FuaXphdGlvbi1pZCI6IndmbW4wODBlaWY4cm5pd3EifQ.a435J9ccjs9V_FzQMdbwTvXOYU8hvRieYkXM7yumlWAJyxDTsq4mi3CP1Ob9y6nLEKr35TYqGwxKFSTOW1oxYQ'
|
||||
process.env['GITHUB_REPOSITORY'] = 'Warpbuilds/backend-cache'
|
||||
process.env['GITHUB_REF'] = 'refs/heads/main'
|
||||
|
||||
// saveCache(
|
||||
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
|
||||
// 'test-fs-local-key',
|
||||
// true
|
||||
// )
|
||||
saveCache(
|
||||
['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
|
||||
'test-fs-local-key',
|
||||
true
|
||||
)
|
||||
|
||||
// saveCache(
|
||||
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
|
||||
|
|
Loading…
Reference in New Issue