From df46e813e639f7f07c35b53559c60dfa227be10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sindri=20Gu=C3=B0mundsson?= Date: Thu, 4 Nov 2021 09:45:24 +0000 Subject: [PATCH] Add option to specify URL of cache server --- action.yml | 3 +++ dist/restore/index.js | 10 +++++++++- dist/save/index.js | 10 +++++++++- src/restore.ts | 1 + src/save.ts | 1 + src/utils/actionUtils.ts | 7 +++++++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 323a4bd..9371682 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,9 @@ inputs: upload-chunk-size: description: 'The chunk size used to split up large files during upload, in bytes' required: false + cache-url: + description: 'The URL of the cache server' + required: false outputs: cache-hit: description: 'A boolean value to indicate an exact match was found for the primary key' diff --git a/dist/restore/index.js b/dist/restore/index.js index 671451c..ccd168e 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -36328,7 +36328,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; +exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.setActionsCacheUrl = exports.isExactKeyMatch = exports.isGhes = void 0; const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(196); function isGhes() { @@ -36343,6 +36343,13 @@ function isExactKeyMatch(key, cacheKey) { }) === 0); } exports.isExactKeyMatch = isExactKeyMatch; +function setActionsCacheUrl() { + const requestedCacheUrl = core.getInput("cache-url"); + if (requestedCacheUrl) { + process.env.ACTIONS_CACHE_URL = requestedCacheUrl; + } +} +exports.setActionsCacheUrl = setActionsCacheUrl; function setCacheState(state) { core.saveState(constants_1.State.CacheMatchedKey, state); } @@ -46719,6 +46726,7 @@ const utils = __importStar(__webpack_require__(443)); function run() { return __awaiter(this, void 0, void 0, function* () { try { + utils.setActionsCacheUrl(); if (utils.isGhes()) { utils.logWarning("Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"); utils.setCacheHitOutput(false); diff --git a/dist/save/index.js b/dist/save/index.js index b0d491d..c1883a5 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -36328,7 +36328,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; +exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.setActionsCacheUrl = exports.isExactKeyMatch = exports.isGhes = void 0; const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(196); function isGhes() { @@ -36343,6 +36343,13 @@ function isExactKeyMatch(key, cacheKey) { }) === 0); } exports.isExactKeyMatch = isExactKeyMatch; +function setActionsCacheUrl() { + const requestedCacheUrl = core.getInput("cache-url"); + if (requestedCacheUrl) { + process.env.ACTIONS_CACHE_URL = requestedCacheUrl; + } +} +exports.setActionsCacheUrl = setActionsCacheUrl; function setCacheState(state) { core.saveState(constants_1.State.CacheMatchedKey, state); } @@ -44905,6 +44912,7 @@ process.on("uncaughtException", e => utils.logWarning(e.message)); function run() { return __awaiter(this, void 0, void 0, function* () { try { + utils.setActionsCacheUrl(); if (utils.isGhes()) { utils.logWarning("Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"); return; diff --git a/src/restore.ts b/src/restore.ts index d411459..5359cf8 100644 --- a/src/restore.ts +++ b/src/restore.ts @@ -6,6 +6,7 @@ import * as utils from "./utils/actionUtils"; async function run(): Promise { try { + utils.setActionsCacheUrl(); if (utils.isGhes()) { utils.logWarning( "Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details" diff --git a/src/save.ts b/src/save.ts index fc0eb73..5a625d6 100644 --- a/src/save.ts +++ b/src/save.ts @@ -11,6 +11,7 @@ process.on("uncaughtException", e => utils.logWarning(e.message)); async function run(): Promise { try { + utils.setActionsCacheUrl(); if (utils.isGhes()) { utils.logWarning( "Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details" diff --git a/src/utils/actionUtils.ts b/src/utils/actionUtils.ts index a4d712d..8edb31a 100644 --- a/src/utils/actionUtils.ts +++ b/src/utils/actionUtils.ts @@ -18,6 +18,13 @@ export function isExactKeyMatch(key: string, cacheKey?: string): boolean { ); } +export function setActionsCacheUrl(): void { + const requestedCacheUrl = core.getInput("cache-url"); + if (requestedCacheUrl) { + process.env.ACTIONS_CACHE_URL = requestedCacheUrl; + } +} + export function setCacheState(state: string): void { core.saveState(State.CacheMatchedKey, state); }