Skip to content

Commit 42af402

Browse files
committed
Add getMostRecentActionsCacheEntry()
1 parent d3197b1 commit 42af402

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/api-client.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,26 @@ export async function listActionsCaches(
229229
);
230230
}
231231

232+
/**
233+
* List the most recently created Actions cache entry across all refs that
234+
* match the provided key.
235+
*/
236+
export async function getMostRecentActionsCacheEntry(
237+
key: string,
238+
): Promise<ActionsCacheItem | undefined> {
239+
const repositoryNwo = getRepositoryNwo();
240+
241+
const cacheItems = await getApiClient().rest.actions.getActionsCacheList({
242+
owner: repositoryNwo.owner,
243+
repo: repositoryNwo.repo,
244+
key,
245+
sort: "created_at",
246+
direction: "desc",
247+
per_page: 1,
248+
});
249+
return cacheItems.data.actions_caches[0];
250+
}
251+
232252
/** Delete an Actions cache item by its ID. */
233253
export async function deleteActionsCache(id: number) {
234254
const repositoryNwo = getRepositoryNwo();

0 commit comments

Comments
 (0)