From ef45800e5cfcedc91d331c79dab5e8e59da3421d Mon Sep 17 00:00:00 2001 From: Chuan-kai Lin Date: Wed, 24 Sep 2025 14:45:58 -0700 Subject: [PATCH] Add getMostRecentActionsCacheEntry() --- src/api-client.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/api-client.ts b/src/api-client.ts index 86134b7f8..134fdb01d 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -260,6 +260,26 @@ export async function listActionsCaches( ); } +/** + * List the most recently created Actions cache entry across all refs that + * match the provided key. + */ +export async function getMostRecentActionsCacheEntry( + key: string, +): Promise { + const repositoryNwo = getRepositoryNwo(); + + const cacheItems = await getApiClient().rest.actions.getActionsCacheList({ + owner: repositoryNwo.owner, + repo: repositoryNwo.repo, + key, + sort: "created_at", + direction: "desc", + per_page: 1, + }); + return cacheItems.data.actions_caches[0]; +} + /** Delete an Actions cache item by its ID. */ export async function deleteActionsCache(id: number) { const repositoryNwo = getRepositoryNwo();