Look at ref rather than default branch

Since we'll only cleanup when running on the default branch
This commit is contained in:
Henry Mercer 2024-05-21 20:47:24 +01:00
parent 087f0b04c6
commit 4fd6c0d4f1
3 changed files with 3 additions and 15 deletions

7
lib/trap-caching.js generated
View file

@ -145,12 +145,7 @@ async function cleanupTrapCaches(language, logger) {
}
exports.cleanupTrapCaches = cleanupTrapCaches;
async function getTrapCachesForLanguage(language) {
const event = actionsUtil.getWorkflowEvent();
const defaultBranch = event?.repository?.default_branch;
if (!defaultBranch) {
throw new Error("Could not determine default branch");
}
const allCaches = await apiClient.listActionsCaches(CODEQL_TRAP_CACHE_PREFIX, defaultBranch);
const allCaches = await apiClient.listActionsCaches(CODEQL_TRAP_CACHE_PREFIX, await actionsUtil.getRef());
return allCaches.filter((cache) => {
return cache.key?.includes(`-${language}-`);
});

File diff suppressed because one or more lines are too long

View file

@ -175,16 +175,9 @@ export async function cleanupTrapCaches(language: Language, logger: Logger) {
async function getTrapCachesForLanguage(
language: Language,
): Promise<apiClient.ActionsCacheItem[]> {
const event = actionsUtil.getWorkflowEvent();
const defaultBranch = event?.repository?.default_branch as string | undefined;
if (!defaultBranch) {
throw new Error("Could not determine default branch");
}
const allCaches = await apiClient.listActionsCaches(
CODEQL_TRAP_CACHE_PREFIX,
defaultBranch,
await actionsUtil.getRef(),
);
return allCaches.filter((cache) => {