From 63c9c00d1d3b870446a8ad02595604476202f13d Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 4 Oct 2022 23:24:31 +0800 Subject: [PATCH] ci: add clear cache tool --- build/clearCache.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 build/clearCache.js diff --git a/build/clearCache.js b/build/clearCache.js new file mode 100644 index 00000000..ca128f04 --- /dev/null +++ b/build/clearCache.js @@ -0,0 +1,16 @@ +const superagent = require('superagent'); +const secret = process.env.GITHUB_TOKEN; +async function main() { + const res = await superagent.get('https://api.github.com/repos/hydro-dev/Hydro/actions/caches') + .set('Accept', 'application/vnd.github+json') + .set('User-Agent', 'Hydro') + .set('Authorization', `Bearer ${secret}`); + console.log(`Total ${res.body.total_count}`); + console.log(res.body.actions_caches.map((i) => i.key)); + await Promise.all(res.body.actions_caches.map((i) => superagent + .delete(`https://api.github.com/repos/hydro-dev/Hydro/actions/caches?key=${i.key}`) + .set('Accept', 'application/vnd.github+json') + .set('User-Agent', 'Hydro') + .set('Authorization', `Bearer ${secret}`))); +} +main();