1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-19 19:46:17 +02:00

Add option to specify URL of cache server

This commit is contained in:
Sindri Guðmundsson 2021-11-04 09:45:24 +00:00 committed by Davíð Guðni
parent 611465405c
commit df46e813e6
6 changed files with 30 additions and 2 deletions

View file

@ -14,6 +14,9 @@ inputs:
upload-chunk-size: upload-chunk-size:
description: 'The chunk size used to split up large files during upload, in bytes' description: 'The chunk size used to split up large files during upload, in bytes'
required: false required: false
cache-url:
description: 'The URL of the cache server'
required: false
outputs: outputs:
cache-hit: cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key' description: 'A boolean value to indicate an exact match was found for the primary key'

10
dist/restore/index.js vendored
View file

@ -36328,7 +36328,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); 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 core = __importStar(__webpack_require__(470));
const constants_1 = __webpack_require__(196); const constants_1 = __webpack_require__(196);
function isGhes() { function isGhes() {
@ -36343,6 +36343,13 @@ function isExactKeyMatch(key, cacheKey) {
}) === 0); }) === 0);
} }
exports.isExactKeyMatch = isExactKeyMatch; 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) { function setCacheState(state) {
core.saveState(constants_1.State.CacheMatchedKey, state); core.saveState(constants_1.State.CacheMatchedKey, state);
} }
@ -46719,6 +46726,7 @@ const utils = __importStar(__webpack_require__(443));
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
utils.setActionsCacheUrl();
if (utils.isGhes()) { if (utils.isGhes()) {
utils.logWarning("Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"); utils.logWarning("Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details");
utils.setCacheHitOutput(false); utils.setCacheHitOutput(false);

10
dist/save/index.js vendored
View file

@ -36328,7 +36328,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); 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 core = __importStar(__webpack_require__(470));
const constants_1 = __webpack_require__(196); const constants_1 = __webpack_require__(196);
function isGhes() { function isGhes() {
@ -36343,6 +36343,13 @@ function isExactKeyMatch(key, cacheKey) {
}) === 0); }) === 0);
} }
exports.isExactKeyMatch = isExactKeyMatch; 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) { function setCacheState(state) {
core.saveState(constants_1.State.CacheMatchedKey, state); core.saveState(constants_1.State.CacheMatchedKey, state);
} }
@ -44905,6 +44912,7 @@ process.on("uncaughtException", e => utils.logWarning(e.message));
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
utils.setActionsCacheUrl();
if (utils.isGhes()) { if (utils.isGhes()) {
utils.logWarning("Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"); utils.logWarning("Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details");
return; return;

View file

@ -6,6 +6,7 @@ import * as utils from "./utils/actionUtils";
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
utils.setActionsCacheUrl();
if (utils.isGhes()) { if (utils.isGhes()) {
utils.logWarning( utils.logWarning(
"Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details" "Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"

View file

@ -11,6 +11,7 @@ process.on("uncaughtException", e => utils.logWarning(e.message));
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
utils.setActionsCacheUrl();
if (utils.isGhes()) { if (utils.isGhes()) {
utils.logWarning( utils.logWarning(
"Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details" "Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"

View file

@ -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 { export function setCacheState(state: string): void {
core.saveState(State.CacheMatchedKey, state); core.saveState(State.CacheMatchedKey, state);
} }