2024-02-16 22:14:07 +00:00
|
|
|
import { saveCache } from "@actions/cache";
|
|
|
|
import { getState, warning } from "@actions/core";
|
|
|
|
import { CacheState } from "./action";
|
2024-10-08 15:19:42 +02:00
|
|
|
import { createHash } from "node:crypto";
|
2024-02-16 22:14:07 +00:00
|
|
|
|
|
|
|
(async () => {
|
|
|
|
const state: CacheState = JSON.parse(getState("cache"));
|
|
|
|
if (state.cacheEnabled && !state.cacheHit) {
|
2024-10-08 15:19:42 +02:00
|
|
|
const cacheKey = createHash("sha1").update(state.url).digest("base64");
|
|
|
|
|
2024-02-16 22:14:07 +00:00
|
|
|
try {
|
2024-10-08 15:19:42 +02:00
|
|
|
await saveCache([state.bunPath], cacheKey);
|
2024-02-16 22:14:07 +00:00
|
|
|
process.exit(0);
|
|
|
|
} catch (error) {
|
|
|
|
warning("Failed to save Bun to cache.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|