mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-30 15:15:52 +00:00
Fix script invocations, lint and format.
Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
This commit is contained in:
parent
8ac3d1967f
commit
11a6324cc7
8 changed files with 240 additions and 175 deletions
36
dist/restore-only/index.js
vendored
36
dist/restore-only/index.js
vendored
|
@ -75634,9 +75634,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||
exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.deleteCacheByKey = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0;
|
||||
const cache = __importStar(__nccwpck_require__(5116));
|
||||
const core = __importStar(__nccwpck_require__(7484));
|
||||
const action_1 = __nccwpck_require__(8556);
|
||||
const request_error_1 = __nccwpck_require__(3708);
|
||||
const constants_1 = __nccwpck_require__(7242);
|
||||
const { Octokit } = __nccwpck_require__(8556);
|
||||
function isGhes() {
|
||||
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
||||
|
@ -75661,18 +75661,19 @@ exports.logWarning = logWarning;
|
|||
function deleteCacheByKey(key, owner, repo) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const octokit = new Octokit();
|
||||
const octokit = new action_1.Octokit();
|
||||
let response;
|
||||
try {
|
||||
const gitRef = process.env[constants_1.RefKey];
|
||||
let cacheEntry = yield octokit.rest.actions.getActionsCacheList({
|
||||
const cacheEntry = yield octokit.rest.actions.getActionsCacheList({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
key: key,
|
||||
ref: gitRef
|
||||
});
|
||||
const { data: { total_count, actions_caches } } = cacheEntry;
|
||||
if (total_count !== 1 || total_count !== actions_caches.length) { // leave all find logic to the actual cache implementation. We just want to make sure we're returned a single element so we don't accidentally delete an entry that belongs to a different gitref.
|
||||
if (total_count !== 1 || total_count !== actions_caches.length) {
|
||||
// leave all find logic to the actual cache implementation. We just want to make sure we're returned a single element so we don't accidentally delete an entry that belongs to a different gitref.
|
||||
if (total_count > 1) {
|
||||
exports.logWarning(`More than one cache entry found for key ${key}`);
|
||||
}
|
||||
|
@ -75687,22 +75688,25 @@ function deleteCacheByKey(key, owner, repo) {
|
|||
core.info(`Skip trying to delete cache entry for key ${key}.`);
|
||||
return;
|
||||
}
|
||||
let id = actions_caches[0].id;
|
||||
response = yield octokit.rest.actions.deleteActionsCacheById({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
cache_id: id
|
||||
});
|
||||
if (response.status === 204) {
|
||||
core.info(`Succesfully deleted cache with key: ${key}, id: ${id}`);
|
||||
return 204;
|
||||
const id = actions_caches[0].id;
|
||||
if (id) {
|
||||
response = yield octokit.rest.actions.deleteActionsCacheById({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
cache_id: id
|
||||
});
|
||||
if (response.status === 204) {
|
||||
core.info(`Succesfully deleted cache with key: ${key}, id: ${id}`);
|
||||
return 204;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof request_error_1.RequestError) {
|
||||
let err = e;
|
||||
let errData = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data;
|
||||
exports.logWarning(`Github API reported error: ${err.name} '${err.status}: ${errData === null || errData === void 0 ? void 0 : errData.message}'`);
|
||||
const err = e;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const errMessage = ((_a = err.response) === null || _a === void 0 ? void 0 : _a.data).message;
|
||||
exports.logWarning(`Github API reported error: ${err.name} '${err.status}: ${errMessage}'`);
|
||||
}
|
||||
core.info(`Couldn't delete cache entry for key ${key}.`);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue