Move cache save to runs.post and exit early (#60)

This commit is contained in:
Andy Palmer 2024-02-16 22:14:07 +00:00 committed by GitHub
parent 12944059f7
commit 0f37bd8169
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 139 additions and 44 deletions

15
src/cache-save.ts Normal file
View file

@ -0,0 +1,15 @@
import { saveCache } from "@actions/cache";
import { getState, warning } from "@actions/core";
import { CacheState } from "./action";
(async () => {
const state: CacheState = JSON.parse(getState("cache"));
if (state.cacheEnabled && !state.cacheHit) {
try {
await saveCache([state.bunPath], state.url);
process.exit(0);
} catch (error) {
warning("Failed to save Bun to cache.");
}
}
})();