mirror of
https://github.com/Swatinem/rust-cache
synced 2026-03-20 15:15:51 +00:00
initial commit
This commit is contained in:
commit
99970e092c
12 changed files with 111031 additions and 0 deletions
35
src/restore.ts
Normal file
35
src/restore.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import * as cache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
import { getCaches, isValidEvent } from "./common";
|
||||
|
||||
async function run() {
|
||||
if (!isValidEvent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
core.exportVariable("CARGO_INCREMENTAL", 0);
|
||||
|
||||
const caches = await getCaches();
|
||||
for (const [name, { path, key, restoreKeys }] of Object.entries(caches)) {
|
||||
try {
|
||||
core.startGroup(`Restoring "${path}" from "${key}"…`);
|
||||
const restoreKey = await cache.restoreCache([path], key, restoreKeys);
|
||||
if (restoreKey) {
|
||||
core.info(`Restored "${path}" from cache key "${restoreKey}".`);
|
||||
core.saveState(name, restoreKey);
|
||||
} else {
|
||||
core.info("No cache found.");
|
||||
}
|
||||
} catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
} finally {
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Loading…
Add table
Add a link
Reference in a new issue