Clean up old TRAP caches

This commit is contained in:
Henry Mercer 2024-05-21 23:05:05 +01:00
parent 898dead2d6
commit 610e72285f
7 changed files with 121 additions and 26 deletions

18
lib/api-client.js generated
View file

@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapApiConfigurationError = exports.listActionsCaches = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRelativePath = exports.getGitHubVersion = exports.getGitHubVersionFromApi = exports.getApiClientWithExternalAuth = exports.getApiClient = exports.getApiDetails = exports.DisallowedAPIVersionReason = void 0;
exports.wrapApiConfigurationError = exports.deleteActionsCache = exports.listActionsCaches = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRelativePath = exports.getGitHubVersion = exports.getGitHubVersionFromApi = exports.getApiClientWithExternalAuth = exports.getApiClient = exports.getApiDetails = exports.DisallowedAPIVersionReason = void 0;
const core = __importStar(require("@actions/core"));
const githubUtils = __importStar(require("@actions/github/lib/utils"));
const retry = __importStar(require("@octokit/plugin-retry"));
@ -165,11 +165,9 @@ function computeAutomationID(analysis_key, environment) {
}
exports.computeAutomationID = computeAutomationID;
/** List all Actions cache entries matching the provided key and ref. */
async function listActionsCaches(key, ref, logger) {
async function listActionsCaches(key, ref) {
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
logger.debug(`Retrieving Actions caches for key ${key} and ref ${ref}`);
const apiClient = getApiClient();
return await apiClient.paginate("GET /repos/{owner}/{repo}/actions/caches", {
return await getApiClient().paginate("GET /repos/{owner}/{repo}/actions/caches", {
owner: repositoryNwo.owner,
repo: repositoryNwo.repo,
key,
@ -177,6 +175,16 @@ async function listActionsCaches(key, ref, logger) {
});
}
exports.listActionsCaches = listActionsCaches;
/** Delete an Actions cache item by its ID. */
async function deleteActionsCache(id) {
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
await getApiClient().rest.actions.deleteActionsCacheById({
owner: repositoryNwo.owner,
repo: repositoryNwo.repo,
cache_id: id,
});
}
exports.deleteActionsCache = deleteActionsCache;
function wrapApiConfigurationError(e) {
if ((0, util_1.isHTTPError)(e)) {
if (e.message.includes("API rate limit exceeded for site ID installation") ||