Bump syn from 2.0.60 to 2.0.72 #232
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cache Clean | |
on: | |
workflow_dispatch: | |
inputs: | |
all-branches: | |
type: boolean | |
description: "Delete caches for all branches (nuclear option)" | |
pull_request: | |
types: | |
- closed | |
permissions: | |
actions: write | |
jobs: | |
clear-cache: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delete caches | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let totalDeleted = 0; | |
let totalBytes = 0; | |
let pageSize = 100; | |
let inputs = context.payload.inputs; | |
let ref = context.ref; | |
if (inputs && inputs["all-branches"] == "true") { | |
console.warn("Deleting caches for all branches"); | |
ref = undefined; | |
} | |
function sizeInMb(size) { | |
return (size / 1024 / 1024).toFixed(2); | |
} | |
async function fetchCaches(params) { | |
return github.rest.actions.getActionsCacheList({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
...params | |
}); | |
} | |
async function fetchAllCaches(ref) { | |
let currentPage = 1; | |
let currentCaches = await fetchCaches({ per_page: pageSize, page: currentPage, ref: ref }); | |
let totalCount = currentCaches.data.total_count; | |
let allCaches = currentCaches.data.actions_caches; | |
console.log(`Found ${totalCount} caches for ref ${ref} (page ${currentPage} of ${Math.ceil(totalCount / pageSize)})`); | |
while (true) { | |
if (allCaches.length >= totalCount || currentPage > 100) { | |
break; | |
} else { | |
currentPage++; | |
currentCaches = await fetchCaches({ per_page: pageSize, page: currentPage, ref: ref }); | |
allCaches = allCaches.concat(currentCaches.data.actions_caches); | |
} | |
} | |
return allCaches; | |
} | |
async function deleteCachesForRef(ref) { | |
let caches = await fetchAllCaches(ref); | |
for (let cache of caches) { | |
totalDeleted++; | |
totalBytes += cache.size_in_bytes; | |
await github.rest.actions.deleteActionsCacheById({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
cache_id: cache.id | |
}); | |
console.log(`Deleted cache ${cache.id} (${sizeInMb(cache.size_in_bytes)} MB) for ref ${cache.ref}`); | |
} | |
} | |
await deleteCachesForRef(ref); | |
let totalMb = sizeInMb(totalBytes); | |
console.log(`Clear completed, deleted ${totalDeleted} caches (${totalMb} MB)`); |