Don't cache non-existent Zig cache directory

This commit is contained in:
mlugg
2024-09-18 16:24:30 +01:00
committed by Matthew Lugg
parent e37757dd16
commit a67e68dc5c
+15 -3
View File
@@ -1,3 +1,4 @@
const fs = require('fs').promises;
const core = require('@actions/core');
const github = require('@actions/github');
const cache = require('@actions/cache');
@@ -6,9 +7,20 @@ const common = require('./common');
async function main() {
try {
if (core.getBooleanInput('use-cache')) {
const prefix = await common.getCachePrefix();
const name = prefix + github.context.runId;
await cache.saveCache([await common.getZigCachePath()], name);
const cache_path = await common.getZigCachePath();
let accessible = true;
try {
await fs.access(cache_path, fs.constants.R_OK);
} catch {
accessible = false;
}
if (accessible) {
const prefix = await common.getCachePrefix();
const name = prefix + github.context.runId;
await cache.saveCache([cache_path], name);
}
}
} catch (err) {
core.setFailed(err.message);