Skip to content

Commit 4d933c9

Browse files
committed
test
1 parent 4c4cc6c commit 4d933c9

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

.github/workflows/tests.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,36 +122,42 @@ jobs:
122122
}
123123
*/
124124
125-
const ref = "${{ github.event.pull_request.number || github.ref }}";
126-
const cacheKeysPattern = `tests-bin-${ref}-`;
127-
128-
console.log(`Deleting caches matching pattern: ${cacheKeysPattern}`);
125+
const sha = '${{ github.event.pull_request.head.sha || github.sha }}';
126+
const pr = '${{ github.event.pull_request.number }}';
127+
if (pr) {
128+
ref = "refs/pull/" + pr + "/merge";
129+
} else {
130+
ref = '${{ github.ref }}';
131+
}
129132
130133
// Fetch all cache entries for the repository
131134
const caches = await github.paginate(github.rest.actions.getActionsCacheList, {
132135
owner: context.repo.owner,
133136
repo: context.repo.repo,
134137
per_page: 100,
135-
key: cacheKeysPattern + '*'
138+
ref: ref
136139
});
137140
141+
console.log(caches);
142+
138143
if (caches.data) {
139144
console.log(`Found ${caches.data.actions_caches.length} caches.`);
140-
console.log(caches.data.actions_caches.map(cache => cache.key));
141-
// Filter caches matching the specified pattern
142-
const matchingCaches = caches.data.actions_caches.filter(cache =>
143-
cache.key.startsWith(cacheKeysPattern)
144-
);
145145
146146
// Delete matching caches
147147
for (const cache of matchingCaches) {
148+
if (cache.key.endsWith(sha)) {
149+
console.log(`Skipping cache with key: ${cache.key}`);
150+
continue;
151+
} else {
152+
console.log(`Deleting cache with key: ${cache.key}`);
153+
}
154+
148155
/*
149156
await github.rest.actions.deleteActionsCacheById({
150157
owner: context.repo.owner,
151158
repo: context.repo.repo,
152159
cache_id: cache.id
153160
});
154161
*/
155-
console.log(`Deleted cache with key: ${cache.key}`);
156162
}
157163
}

0 commit comments

Comments
 (0)