mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 08:56:37 +07:00 
			
		
		
		
	Impl separated
This commit is contained in:
		
							
								
								
									
										212
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										212
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							@ -3402,7 +3402,7 @@ const http_client_1 = __webpack_require__(425);
 | 
			
		||||
const auth_1 = __webpack_require__(554);
 | 
			
		||||
const crypto = __importStar(__webpack_require__(417));
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const url_1 = __webpack_require__(835);
 | 
			
		||||
const url_1 = __webpack_require__(414);
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const downloadUtils_1 = __webpack_require__(251);
 | 
			
		||||
@ -35009,7 +35009,7 @@ exports.Path = Path;
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const punycode = __webpack_require__(815);
 | 
			
		||||
const urlParse = __webpack_require__(835).parse;
 | 
			
		||||
const urlParse = __webpack_require__(414).parse;
 | 
			
		||||
const util = __webpack_require__(669);
 | 
			
		||||
const pubsuffix = __webpack_require__(562);
 | 
			
		||||
const Store = __webpack_require__(338).Store;
 | 
			
		||||
@ -36804,7 +36804,12 @@ module.exports = __webpack_require__(141);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 414 */,
 | 
			
		||||
/* 414 */
 | 
			
		||||
/***/ (function(module) {
 | 
			
		||||
 | 
			
		||||
module.exports = require("url");
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 415 */,
 | 
			
		||||
/* 416 */,
 | 
			
		||||
/* 417 */
 | 
			
		||||
@ -38604,7 +38609,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
 | 
			
		||||
 | 
			
		||||
var Stream = _interopDefault(__webpack_require__(794));
 | 
			
		||||
var http = _interopDefault(__webpack_require__(605));
 | 
			
		||||
var Url = _interopDefault(__webpack_require__(835));
 | 
			
		||||
var Url = _interopDefault(__webpack_require__(414));
 | 
			
		||||
var whatwgUrl = _interopDefault(__webpack_require__(70));
 | 
			
		||||
var https = _interopDefault(__webpack_require__(211));
 | 
			
		||||
var zlib = _interopDefault(__webpack_require__(761));
 | 
			
		||||
@ -41335,7 +41340,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(694);
 | 
			
		||||
const restore_1 = __importDefault(__webpack_require__(778));
 | 
			
		||||
const restoreImpl_1 = __importDefault(__webpack_require__(835));
 | 
			
		||||
function runRestoreAction() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (core.getInput(constants_1.Inputs.SaveOnAnyFailure) != "") {
 | 
			
		||||
@ -41345,7 +41350,7 @@ function runRestoreAction() {
 | 
			
		||||
            core.warning(`${constants_1.Inputs.UploadChunkSize} value is passed in the input, this input is invalid for the restore-only action and hence will be ignored`);
 | 
			
		||||
        }
 | 
			
		||||
        core.info("before run");
 | 
			
		||||
        yield (0, restore_1.default)();
 | 
			
		||||
        yield (0, restoreImpl_1.default)();
 | 
			
		||||
        core.info("after run");
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
@ -49016,102 +49021,7 @@ module.exports = function(dst, src) {
 | 
			
		||||
/* 775 */,
 | 
			
		||||
/* 776 */,
 | 
			
		||||
/* 777 */,
 | 
			
		||||
/* 778 */
 | 
			
		||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
 | 
			
		||||
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
 | 
			
		||||
    if (k2 === undefined) k2 = k;
 | 
			
		||||
    var desc = Object.getOwnPropertyDescriptor(m, k);
 | 
			
		||||
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 | 
			
		||||
      desc = { enumerable: true, get: function() { return m[k]; } };
 | 
			
		||||
    }
 | 
			
		||||
    Object.defineProperty(o, k2, desc);
 | 
			
		||||
}) : (function(o, m, k, k2) {
 | 
			
		||||
    if (k2 === undefined) k2 = k;
 | 
			
		||||
    o[k2] = m[k];
 | 
			
		||||
}));
 | 
			
		||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
 | 
			
		||||
    Object.defineProperty(o, "default", { enumerable: true, value: v });
 | 
			
		||||
}) : function(o, v) {
 | 
			
		||||
    o["default"] = v;
 | 
			
		||||
});
 | 
			
		||||
var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    if (mod && mod.__esModule) return mod;
 | 
			
		||||
    var result = {};
 | 
			
		||||
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
 | 
			
		||||
    __setModuleDefault(result, mod);
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
 | 
			
		||||
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
 | 
			
		||||
    return new (P || (P = Promise))(function (resolve, reject) {
 | 
			
		||||
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
 | 
			
		||||
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
 | 
			
		||||
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
 | 
			
		||||
        step((generator = generator.apply(thisArg, _arguments || [])).next());
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const cache = __importStar(__webpack_require__(692));
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(694);
 | 
			
		||||
const utils = __importStar(__webpack_require__(443));
 | 
			
		||||
function run() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            if (!utils.isCacheFeatureAvailable()) {
 | 
			
		||||
                utils.setCacheHitOutput(false);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Validate inputs, this can cause task failure
 | 
			
		||||
            if (!utils.isValidEvent()) {
 | 
			
		||||
                utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
 | 
			
		||||
            core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
 | 
			
		||||
            const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
 | 
			
		||||
            //Check if user wants to save cache despite of failure in any previous job
 | 
			
		||||
            const saveCache = core.getInput(constants_1.Inputs.SaveOnAnyFailure);
 | 
			
		||||
            if (saveCache === "yes") {
 | 
			
		||||
                core.debug(`save cache input variable is set to yes`);
 | 
			
		||||
                core.exportVariable(constants_1.Variables.SaveCacheOnAnyFailure, saveCache);
 | 
			
		||||
                core.info(`Input Variable ${constants_1.Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`);
 | 
			
		||||
            }
 | 
			
		||||
            if (!cacheKey) {
 | 
			
		||||
                if (core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                    throw new Error(`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`);
 | 
			
		||||
                }
 | 
			
		||||
                core.info(`Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
                    ...restoreKeys
 | 
			
		||||
                ].join(", ")}`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Store the matched cache key
 | 
			
		||||
            utils.setCacheState(cacheKey);
 | 
			
		||||
            const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
            utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
            if (!isExactKeyMatch && core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                throw new Error(`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`);
 | 
			
		||||
            }
 | 
			
		||||
            core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            core.setFailed(error.message);
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.default = run;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 778 */,
 | 
			
		||||
/* 779 */
 | 
			
		||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
 | 
			
		||||
 | 
			
		||||
@ -49550,7 +49460,7 @@ var util = __webpack_require__(669);
 | 
			
		||||
var path = __webpack_require__(622);
 | 
			
		||||
var http = __webpack_require__(605);
 | 
			
		||||
var https = __webpack_require__(211);
 | 
			
		||||
var parseUrl = __webpack_require__(835).parse;
 | 
			
		||||
var parseUrl = __webpack_require__(414).parse;
 | 
			
		||||
var fs = __webpack_require__(747);
 | 
			
		||||
var Stream = __webpack_require__(794).Stream;
 | 
			
		||||
var mime = __webpack_require__(779);
 | 
			
		||||
@ -50716,9 +50626,99 @@ exports.VERSION = '1.0.4';
 | 
			
		||||
/* 833 */,
 | 
			
		||||
/* 834 */,
 | 
			
		||||
/* 835 */
 | 
			
		||||
/***/ (function(module) {
 | 
			
		||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
 | 
			
		||||
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
 | 
			
		||||
    if (k2 === undefined) k2 = k;
 | 
			
		||||
    var desc = Object.getOwnPropertyDescriptor(m, k);
 | 
			
		||||
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 | 
			
		||||
      desc = { enumerable: true, get: function() { return m[k]; } };
 | 
			
		||||
    }
 | 
			
		||||
    Object.defineProperty(o, k2, desc);
 | 
			
		||||
}) : (function(o, m, k, k2) {
 | 
			
		||||
    if (k2 === undefined) k2 = k;
 | 
			
		||||
    o[k2] = m[k];
 | 
			
		||||
}));
 | 
			
		||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
 | 
			
		||||
    Object.defineProperty(o, "default", { enumerable: true, value: v });
 | 
			
		||||
}) : function(o, v) {
 | 
			
		||||
    o["default"] = v;
 | 
			
		||||
});
 | 
			
		||||
var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    if (mod && mod.__esModule) return mod;
 | 
			
		||||
    var result = {};
 | 
			
		||||
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
 | 
			
		||||
    __setModuleDefault(result, mod);
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
 | 
			
		||||
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
 | 
			
		||||
    return new (P || (P = Promise))(function (resolve, reject) {
 | 
			
		||||
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
 | 
			
		||||
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
 | 
			
		||||
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
 | 
			
		||||
        step((generator = generator.apply(thisArg, _arguments || [])).next());
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const cache = __importStar(__webpack_require__(692));
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(694);
 | 
			
		||||
const utils = __importStar(__webpack_require__(443));
 | 
			
		||||
function run() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            if (!utils.isCacheFeatureAvailable()) {
 | 
			
		||||
                utils.setCacheHitOutput(false);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Validate inputs, this can cause task failure
 | 
			
		||||
            if (!utils.isValidEvent()) {
 | 
			
		||||
                utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
 | 
			
		||||
            core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
 | 
			
		||||
            const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
 | 
			
		||||
            //Check if user wants to save cache despite of failure in any previous job
 | 
			
		||||
            const saveCache = core.getInput(constants_1.Inputs.SaveOnAnyFailure);
 | 
			
		||||
            if (saveCache === "yes") {
 | 
			
		||||
                core.debug(`save cache input variable is set to yes`);
 | 
			
		||||
                core.exportVariable(constants_1.Variables.SaveCacheOnAnyFailure, saveCache);
 | 
			
		||||
                core.info(`Input Variable ${constants_1.Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`);
 | 
			
		||||
            }
 | 
			
		||||
            if (!cacheKey) {
 | 
			
		||||
                if (core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                    throw new Error(`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`);
 | 
			
		||||
                }
 | 
			
		||||
                core.info(`Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
                    ...restoreKeys
 | 
			
		||||
                ].join(", ")}`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Store the matched cache key
 | 
			
		||||
            utils.setCacheState(cacheKey);
 | 
			
		||||
            const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
            utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
            if (!isExactKeyMatch && core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                throw new Error(`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`);
 | 
			
		||||
            }
 | 
			
		||||
            core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            core.setFailed(error.message);
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.default = run;
 | 
			
		||||
 | 
			
		||||
module.exports = require("url");
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 836 */,
 | 
			
		||||
@ -55853,7 +55853,7 @@ var stream = __webpack_require__(794);
 | 
			
		||||
var FormData = __webpack_require__(790);
 | 
			
		||||
var node_fetch = __webpack_require__(454);
 | 
			
		||||
var coreTracing = __webpack_require__(263);
 | 
			
		||||
var url = __webpack_require__(835);
 | 
			
		||||
var url = __webpack_require__(414);
 | 
			
		||||
__webpack_require__(97);
 | 
			
		||||
 | 
			
		||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										224
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										224
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							@ -34,7 +34,7 @@ module.exports =
 | 
			
		||||
/******/ 	// the startup function
 | 
			
		||||
/******/ 	function startup() {
 | 
			
		||||
/******/ 		// Load entry module and return exports
 | 
			
		||||
/******/ 		return __webpack_require__(156);
 | 
			
		||||
/******/ 		return __webpack_require__(778);
 | 
			
		||||
/******/ 	};
 | 
			
		||||
/******/
 | 
			
		||||
/******/ 	// run startup
 | 
			
		||||
@ -3402,7 +3402,7 @@ const http_client_1 = __webpack_require__(425);
 | 
			
		||||
const auth_1 = __webpack_require__(554);
 | 
			
		||||
const crypto = __importStar(__webpack_require__(417));
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const url_1 = __webpack_require__(835);
 | 
			
		||||
const url_1 = __webpack_require__(414);
 | 
			
		||||
const utils = __importStar(__webpack_require__(15));
 | 
			
		||||
const constants_1 = __webpack_require__(931);
 | 
			
		||||
const downloadUtils_1 = __webpack_require__(251);
 | 
			
		||||
@ -4612,34 +4612,7 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
 | 
			
		||||
/* 153 */,
 | 
			
		||||
/* 154 */,
 | 
			
		||||
/* 155 */,
 | 
			
		||||
/* 156 */
 | 
			
		||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
 | 
			
		||||
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
 | 
			
		||||
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
 | 
			
		||||
    return new (P || (P = Promise))(function (resolve, reject) {
 | 
			
		||||
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
 | 
			
		||||
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
 | 
			
		||||
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
 | 
			
		||||
        step((generator = generator.apply(thisArg, _arguments || [])).next());
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
			
		||||
    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const restore_1 = __importDefault(__webpack_require__(778));
 | 
			
		||||
function runRestoreStep() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        yield (0, restore_1.default)();
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
runRestoreStep();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 156 */,
 | 
			
		||||
/* 157 */
 | 
			
		||||
/***/ (function(module, __unusedexports, __webpack_require__) {
 | 
			
		||||
 | 
			
		||||
@ -35051,7 +35024,7 @@ exports.Path = Path;
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const punycode = __webpack_require__(815);
 | 
			
		||||
const urlParse = __webpack_require__(835).parse;
 | 
			
		||||
const urlParse = __webpack_require__(414).parse;
 | 
			
		||||
const util = __webpack_require__(669);
 | 
			
		||||
const pubsuffix = __webpack_require__(562);
 | 
			
		||||
const Store = __webpack_require__(338).Store;
 | 
			
		||||
@ -36846,7 +36819,12 @@ module.exports = __webpack_require__(141);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 414 */,
 | 
			
		||||
/* 414 */
 | 
			
		||||
/***/ (function(module) {
 | 
			
		||||
 | 
			
		||||
module.exports = require("url");
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 415 */,
 | 
			
		||||
/* 416 */,
 | 
			
		||||
/* 417 */
 | 
			
		||||
@ -38646,7 +38624,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
 | 
			
		||||
 | 
			
		||||
var Stream = _interopDefault(__webpack_require__(794));
 | 
			
		||||
var http = _interopDefault(__webpack_require__(605));
 | 
			
		||||
var Url = _interopDefault(__webpack_require__(835));
 | 
			
		||||
var Url = _interopDefault(__webpack_require__(414));
 | 
			
		||||
var whatwgUrl = _interopDefault(__webpack_require__(70));
 | 
			
		||||
var https = _interopDefault(__webpack_require__(211));
 | 
			
		||||
var zlib = _interopDefault(__webpack_require__(761));
 | 
			
		||||
@ -48985,29 +48963,6 @@ module.exports = function(dst, src) {
 | 
			
		||||
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
 | 
			
		||||
    if (k2 === undefined) k2 = k;
 | 
			
		||||
    var desc = Object.getOwnPropertyDescriptor(m, k);
 | 
			
		||||
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 | 
			
		||||
      desc = { enumerable: true, get: function() { return m[k]; } };
 | 
			
		||||
    }
 | 
			
		||||
    Object.defineProperty(o, k2, desc);
 | 
			
		||||
}) : (function(o, m, k, k2) {
 | 
			
		||||
    if (k2 === undefined) k2 = k;
 | 
			
		||||
    o[k2] = m[k];
 | 
			
		||||
}));
 | 
			
		||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
 | 
			
		||||
    Object.defineProperty(o, "default", { enumerable: true, value: v });
 | 
			
		||||
}) : function(o, v) {
 | 
			
		||||
    o["default"] = v;
 | 
			
		||||
});
 | 
			
		||||
var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    if (mod && mod.__esModule) return mod;
 | 
			
		||||
    var result = {};
 | 
			
		||||
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
 | 
			
		||||
    __setModuleDefault(result, mod);
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
 | 
			
		||||
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
 | 
			
		||||
    return new (P || (P = Promise))(function (resolve, reject) {
 | 
			
		||||
@ -49017,62 +48972,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
 | 
			
		||||
        step((generator = generator.apply(thisArg, _arguments || [])).next());
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
			
		||||
    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const cache = __importStar(__webpack_require__(692));
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(196);
 | 
			
		||||
const utils = __importStar(__webpack_require__(443));
 | 
			
		||||
function run() {
 | 
			
		||||
const restoreImpl_1 = __importDefault(__webpack_require__(835));
 | 
			
		||||
function runRestoreStep() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            if (!utils.isCacheFeatureAvailable()) {
 | 
			
		||||
                utils.setCacheHitOutput(false);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Validate inputs, this can cause task failure
 | 
			
		||||
            if (!utils.isValidEvent()) {
 | 
			
		||||
                utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
 | 
			
		||||
            core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
 | 
			
		||||
            const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
 | 
			
		||||
            //Check if user wants to save cache despite of failure in any previous job
 | 
			
		||||
            const saveCache = core.getInput(constants_1.Inputs.SaveOnAnyFailure);
 | 
			
		||||
            if (saveCache === "yes") {
 | 
			
		||||
                core.debug(`save cache input variable is set to yes`);
 | 
			
		||||
                core.exportVariable(constants_1.Variables.SaveCacheOnAnyFailure, saveCache);
 | 
			
		||||
                core.info(`Input Variable ${constants_1.Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`);
 | 
			
		||||
            }
 | 
			
		||||
            if (!cacheKey) {
 | 
			
		||||
                if (core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                    throw new Error(`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`);
 | 
			
		||||
                }
 | 
			
		||||
                core.info(`Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
                    ...restoreKeys
 | 
			
		||||
                ].join(", ")}`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Store the matched cache key
 | 
			
		||||
            utils.setCacheState(cacheKey);
 | 
			
		||||
            const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
            utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
            if (!isExactKeyMatch && core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                throw new Error(`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`);
 | 
			
		||||
            }
 | 
			
		||||
            core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            core.setFailed(error.message);
 | 
			
		||||
        }
 | 
			
		||||
        yield (0, restoreImpl_1.default)();
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.default = run;
 | 
			
		||||
runRestoreStep();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
@ -49514,7 +49424,7 @@ var util = __webpack_require__(669);
 | 
			
		||||
var path = __webpack_require__(622);
 | 
			
		||||
var http = __webpack_require__(605);
 | 
			
		||||
var https = __webpack_require__(211);
 | 
			
		||||
var parseUrl = __webpack_require__(835).parse;
 | 
			
		||||
var parseUrl = __webpack_require__(414).parse;
 | 
			
		||||
var fs = __webpack_require__(747);
 | 
			
		||||
var Stream = __webpack_require__(794).Stream;
 | 
			
		||||
var mime = __webpack_require__(779);
 | 
			
		||||
@ -50680,9 +50590,99 @@ exports.VERSION = '1.0.4';
 | 
			
		||||
/* 833 */,
 | 
			
		||||
/* 834 */,
 | 
			
		||||
/* 835 */
 | 
			
		||||
/***/ (function(module) {
 | 
			
		||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
 | 
			
		||||
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
 | 
			
		||||
    if (k2 === undefined) k2 = k;
 | 
			
		||||
    var desc = Object.getOwnPropertyDescriptor(m, k);
 | 
			
		||||
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 | 
			
		||||
      desc = { enumerable: true, get: function() { return m[k]; } };
 | 
			
		||||
    }
 | 
			
		||||
    Object.defineProperty(o, k2, desc);
 | 
			
		||||
}) : (function(o, m, k, k2) {
 | 
			
		||||
    if (k2 === undefined) k2 = k;
 | 
			
		||||
    o[k2] = m[k];
 | 
			
		||||
}));
 | 
			
		||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
 | 
			
		||||
    Object.defineProperty(o, "default", { enumerable: true, value: v });
 | 
			
		||||
}) : function(o, v) {
 | 
			
		||||
    o["default"] = v;
 | 
			
		||||
});
 | 
			
		||||
var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    if (mod && mod.__esModule) return mod;
 | 
			
		||||
    var result = {};
 | 
			
		||||
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
 | 
			
		||||
    __setModuleDefault(result, mod);
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
 | 
			
		||||
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
 | 
			
		||||
    return new (P || (P = Promise))(function (resolve, reject) {
 | 
			
		||||
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
 | 
			
		||||
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
 | 
			
		||||
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
 | 
			
		||||
        step((generator = generator.apply(thisArg, _arguments || [])).next());
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
const cache = __importStar(__webpack_require__(692));
 | 
			
		||||
const core = __importStar(__webpack_require__(470));
 | 
			
		||||
const constants_1 = __webpack_require__(196);
 | 
			
		||||
const utils = __importStar(__webpack_require__(443));
 | 
			
		||||
function run() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            if (!utils.isCacheFeatureAvailable()) {
 | 
			
		||||
                utils.setCacheHitOutput(false);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Validate inputs, this can cause task failure
 | 
			
		||||
            if (!utils.isValidEvent()) {
 | 
			
		||||
                utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
 | 
			
		||||
            core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
 | 
			
		||||
            const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
 | 
			
		||||
            const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
 | 
			
		||||
                required: true
 | 
			
		||||
            });
 | 
			
		||||
            const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
 | 
			
		||||
            //Check if user wants to save cache despite of failure in any previous job
 | 
			
		||||
            const saveCache = core.getInput(constants_1.Inputs.SaveOnAnyFailure);
 | 
			
		||||
            if (saveCache === "yes") {
 | 
			
		||||
                core.debug(`save cache input variable is set to yes`);
 | 
			
		||||
                core.exportVariable(constants_1.Variables.SaveCacheOnAnyFailure, saveCache);
 | 
			
		||||
                core.info(`Input Variable ${constants_1.Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`);
 | 
			
		||||
            }
 | 
			
		||||
            if (!cacheKey) {
 | 
			
		||||
                if (core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                    throw new Error(`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`);
 | 
			
		||||
                }
 | 
			
		||||
                core.info(`Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
                    ...restoreKeys
 | 
			
		||||
                ].join(", ")}`);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // Store the matched cache key
 | 
			
		||||
            utils.setCacheState(cacheKey);
 | 
			
		||||
            const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
            utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
            if (!isExactKeyMatch && core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                throw new Error(`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`);
 | 
			
		||||
            }
 | 
			
		||||
            core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            core.setFailed(error.message);
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.default = run;
 | 
			
		||||
 | 
			
		||||
module.exports = require("url");
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
/* 836 */,
 | 
			
		||||
@ -55817,7 +55817,7 @@ var stream = __webpack_require__(794);
 | 
			
		||||
var FormData = __webpack_require__(790);
 | 
			
		||||
var node_fetch = __webpack_require__(454);
 | 
			
		||||
var coreTracing = __webpack_require__(263);
 | 
			
		||||
var url = __webpack_require__(835);
 | 
			
		||||
var url = __webpack_require__(414);
 | 
			
		||||
__webpack_require__(97);
 | 
			
		||||
 | 
			
		||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@
 | 
			
		||||
  "description": "Cache dependencies and build outputs",
 | 
			
		||||
  "main": "dist/restore/index.js",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "tsc && ncc build -o dist/restore src/restore-step.ts && ncc build -o dist/save src/save.ts && ncc build -o dist/restore-only src/restore/restore-only.ts",
 | 
			
		||||
    "build": "tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts && ncc build -o dist/restore-only src/restore/restore-only.ts",
 | 
			
		||||
    "test": "tsc --noEmit && jest --coverage",
 | 
			
		||||
    "lint": "eslint **/*.ts --cache",
 | 
			
		||||
    "format": "prettier --write **/*.ts",
 | 
			
		||||
 | 
			
		||||
@ -1,7 +0,0 @@
 | 
			
		||||
import restore from "./restore";
 | 
			
		||||
 | 
			
		||||
async function runRestoreStep(): Promise<void> {
 | 
			
		||||
    await restore();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
runRestoreStep();
 | 
			
		||||
@ -1,79 +1,7 @@
 | 
			
		||||
import * as cache from "@actions/cache";
 | 
			
		||||
import * as core from "@actions/core";
 | 
			
		||||
import restore from "./restoreImpl";
 | 
			
		||||
 | 
			
		||||
import { Events, Inputs, State, Variables } from "./constants";
 | 
			
		||||
import * as utils from "./utils/actionUtils";
 | 
			
		||||
 | 
			
		||||
async function run(): Promise<void> {
 | 
			
		||||
    try {
 | 
			
		||||
        if (!utils.isCacheFeatureAvailable()) {
 | 
			
		||||
            utils.setCacheHitOutput(false);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Validate inputs, this can cause task failure
 | 
			
		||||
        if (!utils.isValidEvent()) {
 | 
			
		||||
            utils.logWarning(
 | 
			
		||||
                `Event Validation Error: The event type ${
 | 
			
		||||
                    process.env[Events.Key]
 | 
			
		||||
                } is not supported because it's not tied to a branch or tag ref.`
 | 
			
		||||
            );
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const primaryKey = core.getInput(Inputs.Key, { required: true });
 | 
			
		||||
        core.saveState(State.CachePrimaryKey, primaryKey);
 | 
			
		||||
 | 
			
		||||
        const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
 | 
			
		||||
        const cachePaths = utils.getInputAsArray(Inputs.Path, {
 | 
			
		||||
            required: true
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        const cacheKey = await cache.restoreCache(
 | 
			
		||||
            cachePaths,
 | 
			
		||||
            primaryKey,
 | 
			
		||||
            restoreKeys
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        //Check if user wants to save cache despite of failure in any previous job
 | 
			
		||||
        const saveCache = core.getInput(Inputs.SaveOnAnyFailure);
 | 
			
		||||
        if (saveCache === "yes") {
 | 
			
		||||
            core.debug(`save cache input variable is set to yes`);
 | 
			
		||||
            core.exportVariable(Variables.SaveCacheOnAnyFailure, saveCache);
 | 
			
		||||
            core.info(
 | 
			
		||||
                `Input Variable ${Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!cacheKey) {
 | 
			
		||||
            if (core.getInput(Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                throw new Error(
 | 
			
		||||
                    `Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
            core.info(
 | 
			
		||||
                `Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
                    ...restoreKeys
 | 
			
		||||
                ].join(", ")}`
 | 
			
		||||
            );
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        // Store the matched cache key
 | 
			
		||||
        utils.setCacheState(cacheKey);
 | 
			
		||||
 | 
			
		||||
        const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
        utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
 | 
			
		||||
        if (!isExactKeyMatch && core.getInput(Inputs.StrictRestore) == "yes") {
 | 
			
		||||
            throw new Error(
 | 
			
		||||
                `Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
    } catch (error: unknown) {
 | 
			
		||||
        core.setFailed((error as Error).message);
 | 
			
		||||
    }
 | 
			
		||||
async function runRestoreStep(): Promise<void> {
 | 
			
		||||
    await restore();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default run;
 | 
			
		||||
runRestoreStep();
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import * as core from "@actions/core";
 | 
			
		||||
 | 
			
		||||
import { Inputs } from "../constants";
 | 
			
		||||
import restore from "../restore";
 | 
			
		||||
import restore from "../restoreImpl";
 | 
			
		||||
 | 
			
		||||
async function runRestoreAction(): Promise<void> {
 | 
			
		||||
    if (core.getInput(Inputs.SaveOnAnyFailure) != "") {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										79
									
								
								src/restoreImpl.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								src/restoreImpl.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,79 @@
 | 
			
		||||
import * as cache from "@actions/cache";
 | 
			
		||||
import * as core from "@actions/core";
 | 
			
		||||
 | 
			
		||||
import { Events, Inputs, State, Variables } from "./constants";
 | 
			
		||||
import * as utils from "./utils/actionUtils";
 | 
			
		||||
 | 
			
		||||
async function run(): Promise<void> {
 | 
			
		||||
    try {
 | 
			
		||||
        if (!utils.isCacheFeatureAvailable()) {
 | 
			
		||||
            utils.setCacheHitOutput(false);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Validate inputs, this can cause task failure
 | 
			
		||||
        if (!utils.isValidEvent()) {
 | 
			
		||||
            utils.logWarning(
 | 
			
		||||
                `Event Validation Error: The event type ${
 | 
			
		||||
                    process.env[Events.Key]
 | 
			
		||||
                } is not supported because it's not tied to a branch or tag ref.`
 | 
			
		||||
            );
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const primaryKey = core.getInput(Inputs.Key, { required: true });
 | 
			
		||||
        core.saveState(State.CachePrimaryKey, primaryKey);
 | 
			
		||||
 | 
			
		||||
        const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
 | 
			
		||||
        const cachePaths = utils.getInputAsArray(Inputs.Path, {
 | 
			
		||||
            required: true
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        const cacheKey = await cache.restoreCache(
 | 
			
		||||
            cachePaths,
 | 
			
		||||
            primaryKey,
 | 
			
		||||
            restoreKeys
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        //Check if user wants to save cache despite of failure in any previous job
 | 
			
		||||
        const saveCache = core.getInput(Inputs.SaveOnAnyFailure);
 | 
			
		||||
        if (saveCache === "yes") {
 | 
			
		||||
            core.debug(`save cache input variable is set to yes`);
 | 
			
		||||
            core.exportVariable(Variables.SaveCacheOnAnyFailure, saveCache);
 | 
			
		||||
            core.info(
 | 
			
		||||
                `Input Variable ${Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!cacheKey) {
 | 
			
		||||
            if (core.getInput(Inputs.StrictRestore) == "yes") {
 | 
			
		||||
                throw new Error(
 | 
			
		||||
                    `Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
            core.info(
 | 
			
		||||
                `Cache not found for input keys: ${[
 | 
			
		||||
                    primaryKey,
 | 
			
		||||
                    ...restoreKeys
 | 
			
		||||
                ].join(", ")}`
 | 
			
		||||
            );
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        // Store the matched cache key
 | 
			
		||||
        utils.setCacheState(cacheKey);
 | 
			
		||||
 | 
			
		||||
        const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
        utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
 | 
			
		||||
        if (!isExactKeyMatch && core.getInput(Inputs.StrictRestore) == "yes") {
 | 
			
		||||
            throw new Error(
 | 
			
		||||
                `Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
    } catch (error: unknown) {
 | 
			
		||||
        core.setFailed((error as Error).message);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default run;
 | 
			
		||||
		Reference in New Issue
	
	Block a user