List matching Actions caches

This commit is contained in:
Henry Mercer 2024-05-21 15:44:39 +01:00
parent b1bd8da5e7
commit cc96c825ba
9 changed files with 78 additions and 15 deletions

View file

@ -4,6 +4,7 @@ import * as retry from "@octokit/plugin-retry";
import consoleLogLevel from "console-log-level";
import { getActionVersion, getRequiredInput } from "./actions-util";
import { parseRepositoryNwo } from "./repository";
import {
ConfigurationError,
getRequiredEnvParam,
@ -195,6 +196,20 @@ export function computeAutomationID(
return automationID;
}
/** List all Actions cache entries matching the provided key and ref. */
export async function listActionsCaches(key: string, ref: string) {
const repositoryNwo = parseRepositoryNwo(
getRequiredEnvParam("GITHUB_REPOSITORY"),
);
const apiClient = getApiClient();
return await apiClient.paginate(
"GET /repos/{owner}/{repo}/actions/caches",
{ owner: repositoryNwo.owner, repo: repositoryNwo.repo, key, ref },
(response) => response.data.actions_caches,
);
}
export function wrapApiConfigurationError(e: unknown) {
if (isHTTPError(e)) {
if (