From 6b6809a71a4dbbe867203fa3cf7ad16c06d6ea79 Mon Sep 17 00:00:00 2001 From: ryuni-dev Date: Fri, 7 Jul 2023 19:14:26 +0900 Subject: [PATCH 1/2] fix: fix clean-up order --- src/restore/index.ts | 17 +++++++++++++++++ src/save/index.ts | 14 +------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/restore/index.ts b/src/restore/index.ts index 4c810ba..f077103 100644 --- a/src/restore/index.ts +++ b/src/restore/index.ts @@ -9,6 +9,23 @@ import { } from '../utils/cache' async function run(): Promise { + try { + /* + clean up caches + */ + const cacheBase = core.getState('cache-base') + const cleanKey = core.getInput('clean-key') + const CLEAN_TIME = 7 + + if (cleanKey) { + await exec( + `/bin/bash -c "find ${cacheBase} -maxdepth 1 -name '${cleanKey}*' -type d -atime +${CLEAN_TIME} -exec rm -rf {} +"` + ) + } + } catch (error) { + if (error instanceof Error) core.setFailed(error.message) + } + try { const key = core.getInput('key') const base = core.getInput('base') diff --git a/src/save/index.ts b/src/save/index.ts index dfecec0..506edea 100644 --- a/src/save/index.ts +++ b/src/save/index.ts @@ -21,21 +21,9 @@ async function run(): Promise { core.info(`,not saving cache`) } - /* - clean up caches - */ - const cacheBase = core.getState('cache-base') - const cleanKey = core.getInput('clean-key') - const CLEAN_TIME = 7 - - if (cleanKey) { - await exec( - `/bin/bash -c "find ${cacheBase} -maxdepth 1 -name '${cleanKey}*' -type d -atime +${CLEAN_TIME} -exec rm -rf {} +"` - ) - } } catch (error) { if (error instanceof Error) core.setFailed(error.message) } } -run() +run() \ No newline at end of file From a1e7986aa0b29ae1660fb3c1d281b0df9d2ec877 Mon Sep 17 00:00:00 2001 From: ryuni-dev Date: Mon, 10 Jul 2023 09:43:47 +0900 Subject: [PATCH 2/2] fix: error handling --- src/restore/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/restore/index.ts b/src/restore/index.ts index f077103..5180cba 100644 --- a/src/restore/index.ts +++ b/src/restore/index.ts @@ -23,7 +23,7 @@ async function run(): Promise { ) } } catch (error) { - if (error instanceof Error) core.setFailed(error.message) + if (error instanceof Error) core.warning(error.message) } try {