mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-23 17:23:59 +08:00
add support for read-only cache
This commit is contained in:
parent
6babf202a4
commit
a88d0603fe
8 changed files with 79 additions and 3 deletions
7
dist/restore/index.js
vendored
7
dist/restore/index.js
vendored
|
@ -4947,6 +4947,7 @@ var Inputs;
|
|||
Inputs["Path"] = "path";
|
||||
Inputs["RestoreKeys"] = "restore-keys";
|
||||
Inputs["UploadChunkSize"] = "upload-chunk-size";
|
||||
Inputs["ReadOnly"] = "read-only";
|
||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
||||
var Outputs;
|
||||
(function (Outputs) {
|
||||
|
@ -38398,7 +38399,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
|
||||
exports.isCacheFeatureAvailable = exports.getInputAsBoolean = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
|
||||
const cache = __importStar(__webpack_require__(692));
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const constants_1 = __webpack_require__(196);
|
||||
|
@ -38464,6 +38465,10 @@ function getInputAsInt(name, options) {
|
|||
return value;
|
||||
}
|
||||
exports.getInputAsInt = getInputAsInt;
|
||||
function getInputAsBoolean(name, options) {
|
||||
return core.getInput(name, options) === "true";
|
||||
}
|
||||
exports.getInputAsBoolean = getInputAsBoolean;
|
||||
function isCacheFeatureAvailable() {
|
||||
if (!cache.isFeatureAvailable()) {
|
||||
if (isGhes()) {
|
||||
|
|
11
dist/save/index.js
vendored
11
dist/save/index.js
vendored
|
@ -4947,6 +4947,7 @@ var Inputs;
|
|||
Inputs["Path"] = "path";
|
||||
Inputs["RestoreKeys"] = "restore-keys";
|
||||
Inputs["UploadChunkSize"] = "upload-chunk-size";
|
||||
Inputs["ReadOnly"] = "read-only";
|
||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
||||
var Outputs;
|
||||
(function (Outputs) {
|
||||
|
@ -38398,7 +38399,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
|
||||
exports.isCacheFeatureAvailable = exports.getInputAsBoolean = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
|
||||
const cache = __importStar(__webpack_require__(692));
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const constants_1 = __webpack_require__(196);
|
||||
|
@ -38464,6 +38465,10 @@ function getInputAsInt(name, options) {
|
|||
return value;
|
||||
}
|
||||
exports.getInputAsInt = getInputAsInt;
|
||||
function getInputAsBoolean(name, options) {
|
||||
return core.getInput(name, options) === "true";
|
||||
}
|
||||
exports.getInputAsBoolean = getInputAsBoolean;
|
||||
function isCacheFeatureAvailable() {
|
||||
if (!cache.isFeatureAvailable()) {
|
||||
if (isGhes()) {
|
||||
|
@ -47297,6 +47302,10 @@ function run() {
|
|||
return;
|
||||
}
|
||||
const state = utils.getCacheState();
|
||||
if (utils.getInputAsBoolean(constants_1.Inputs.ReadOnly)) {
|
||||
core.info(`Cache is read-only, skipping save.`);
|
||||
return;
|
||||
}
|
||||
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
||||
if (!primaryKey) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue