1
0
Fork 0

Added support to check if Artifact cache service is enabled or not.

pull/1028/head
Shubham Tiwari 2022-03-23 02:24:43 +05:30
parent d1abf7dc74
commit 717b6fd18b
5 changed files with 22 additions and 10 deletions

View File

@ -50,3 +50,6 @@
### 1.0.10 ### 1.0.10
- Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022) - Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022)
### 1.0.10
- Added support to check if Artifact cache service is enabled or not.

4
packages/cache/package-lock.json generated vendored
View File

@ -1,12 +1,12 @@
{ {
"name": "@actions/cache", "name": "@actions/cache",
"version": "1.0.10", "version": "1.0.11",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@actions/cache", "name": "@actions/cache",
"version": "1.0.10", "version": "1.0.11",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",

View File

@ -1,6 +1,6 @@
{ {
"name": "@actions/cache", "name": "@actions/cache",
"version": "1.0.10", "version": "1.0.11",
"preview": true, "preview": true,
"description": "Actions cache lib", "description": "Actions cache lib",
"keywords": [ "keywords": [

View File

@ -43,6 +43,20 @@ function checkKey(key: string): void {
} }
} }
/**
* isEnable to check the presence of Artifact cache service.
*
* @returns boolean
*/
export function isEnable(): boolean{
if (process.env['ACTIONS_CACHE_URL']){
return true;
}
return false;
}
/** /**
* Restores cache from keys * Restores cache from keys
* *

View File

@ -31,12 +31,7 @@ import {
const versionSalt = '1.0' const versionSalt = '1.0'
function getCacheApiUrl(resource: string): string { function getCacheApiUrl(resource: string): string {
// Ideally we just use ACTIONS_CACHE_URL const baseUrl: string = process.env['ACTIONS_CACHE_URL'] || ''
const baseUrl: string = (
process.env['ACTIONS_CACHE_URL'] ||
process.env['ACTIONS_RUNTIME_URL'] ||
''
).replace('pipelines', 'artifactcache')
if (!baseUrl) { if (!baseUrl) {
throw new Error('Cache Service Url not found, unable to restore cache.') throw new Error('Cache Service Url not found, unable to restore cache.')
} }