|
1 |
| -async function getActionsGetActionsCacheList ({ github, context }) { |
| 1 | +async function getActionsGetActionsCacheList({ github, context }) { |
2 | 2 | const actionsGetActionsCacheListParams = {
|
3 | 3 | owner: context.repo.owner,
|
4 | 4 | repo: context.repo.repo,
|
5 |
| - sort: 'last_accessed_at', |
6 |
| - direction: 'asc' |
7 |
| - } |
8 |
| - console.log('call actions.getActionsCacheList', actionsGetActionsCacheListParams) |
| 5 | + sort: "last_accessed_at", |
| 6 | + direction: "asc", |
| 7 | + }; |
| 8 | + console.log( |
| 9 | + "call actions.getActionsCacheList", |
| 10 | + actionsGetActionsCacheListParams, |
| 11 | + ); |
9 | 12 | return github.paginate(
|
10 | 13 | github.rest.actions.getActionsCacheList,
|
11 |
| - actionsGetActionsCacheListParams |
12 |
| - ) |
| 14 | + actionsGetActionsCacheListParams, |
| 15 | + ); |
13 | 16 | }
|
14 | 17 |
|
15 |
| -function getSumSize (actionsGetActionsCacheList) { |
16 |
| - return actionsGetActionsCacheList.reduce((sum, size) => sum + (size.size_in_bytes ?? 0), 0) |
| 18 | +function getSumSize(actionsGetActionsCacheList) { |
| 19 | + return actionsGetActionsCacheList.reduce( |
| 20 | + (sum, size) => sum + (size.size_in_bytes ?? 0), |
| 21 | + 0, |
| 22 | + ); |
17 | 23 | }
|
18 | 24 |
|
19 | 25 | module.exports = async ({ github, context }) => {
|
20 |
| - let actionsGetActionsCacheList = await getActionsGetActionsCacheList({ github, context }) |
21 |
| - let sumSize = getSumSize(actionsGetActionsCacheList) |
| 26 | + let actionsGetActionsCacheList = await getActionsGetActionsCacheList({ |
| 27 | + github, |
| 28 | + context, |
| 29 | + }); |
| 30 | + let sumSize = getSumSize(actionsGetActionsCacheList); |
22 | 31 |
|
23 | 32 | for (let i = 0; i < 40 && 7 * 1024 * 1024 * 1024 < sumSize; i++) {
|
24 |
| - const actionCache = actionsGetActionsCacheList.shift() |
| 33 | + const actionCache = actionsGetActionsCacheList.shift(); |
25 | 34 | const actionsDeleteActionsCacheByKey = {
|
26 | 35 | owner: context.repo.owner,
|
27 | 36 | repo: context.repo.repo,
|
28 |
| - key: actionCache.key |
29 |
| - } |
30 |
| - console.log('call actions.deleteActionsCacheByKey', actionsDeleteActionsCacheByKey) |
| 37 | + key: actionCache.key, |
| 38 | + }; |
| 39 | + console.log( |
| 40 | + "call actions.deleteActionsCacheByKey", |
| 41 | + actionsDeleteActionsCacheByKey, |
| 42 | + ); |
31 | 43 |
|
32 | 44 | try {
|
33 | 45 | await github.rest.actions.deleteActionsCacheByKey(
|
34 |
| - actionsDeleteActionsCacheByKey |
35 |
| - ) |
| 46 | + actionsDeleteActionsCacheByKey, |
| 47 | + ); |
36 | 48 | } catch (e) {
|
37 | 49 | if (e.status === 404) {
|
38 |
| - actionsGetActionsCacheList = await getActionsGetActionsCacheList({ github, context }) |
39 |
| - sumSize = getSumSize(actionsGetActionsCacheList) |
40 |
| - continue |
| 50 | + actionsGetActionsCacheList = await getActionsGetActionsCacheList({ |
| 51 | + github, |
| 52 | + context, |
| 53 | + }); |
| 54 | + sumSize = getSumSize(actionsGetActionsCacheList); |
| 55 | + continue; |
41 | 56 | }
|
42 | 57 |
|
43 |
| - throw e |
| 58 | + throw e; |
44 | 59 | }
|
45 | 60 |
|
46 |
| - sumSize -= actionCache.size_in_bytes |
| 61 | + sumSize -= actionCache.size_in_bytes; |
47 | 62 | }
|
48 |
| -} |
| 63 | +}; |
0 commit comments