@@ -130,34 +130,33 @@ jobs:
130
130
ref = '${{ github.ref }}';
131
131
}
132
132
133
- // Fetch all cache entries for the repository
134
- const caches = await github.paginate(github.rest.actions.getActionsCacheList, {
135
- owner: context.repo.owner,
136
- repo: context.repo.repo,
137
- per_page: 100,
138
- ref: ref
139
- });
140
-
141
- console.log(caches);
142
-
143
- if (caches.data) {
144
- console.log(`Found ${caches.data.actions_caches.length} caches.`);
145
-
146
- // Delete matching caches
147
- 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}`);
133
+ do {
134
+ // Fetch all cache entries for the repository
135
+ const caches = await github.rest.actions.getActionsCacheList({
136
+ owner: context.repo.owner,
137
+ repo: context.repo.repo,
138
+ per_page: 100,
139
+ ref: ref
140
+ });
141
+
142
+ if (caches.data) {
143
+ // Delete matching caches
144
+ for (const cache of matchingCaches) {
145
+ if (cache.key.endsWith(sha)) {
146
+ console.log(`Skipping cache with key: ${cache.key}`);
147
+ continue;
148
+ } else {
149
+ console.log(`Deleting cache with key: ${cache.key}`);
150
+ }
151
+
152
+ /*
153
+ await github.rest.actions.deleteActionsCacheById({
154
+ owner: context.repo.owner,
155
+ repo: context.repo.repo,
156
+ cache_id: cache.id
157
+ });
158
+ */
153
159
}
154
-
155
- /*
156
- await github.rest.actions.deleteActionsCacheById({
157
- owner: context.repo.owner,
158
- repo: context.repo.repo,
159
- cache_id: cache.id
160
- });
161
- */
162
- }
160
+ await sleep(30000); // Sleep for 30 seconds to avoid rate limiting
161
+ } while(caches?.data?.actions_caches?.length > 0);
163
162
}
0 commit comments