Skip to content

Commit a67e68d

Browse files
committed
Don't cache non-existent Zig cache directory
1 parent e37757d commit a67e68d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

post.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fs = require('fs').promises;
12
const core = require('@actions/core');
23
const github = require('@actions/github');
34
const cache = require('@actions/cache');
@@ -6,9 +7,20 @@ const common = require('./common');
67
async function main() {
78
try {
89
if (core.getBooleanInput('use-cache')) {
9-
const prefix = await common.getCachePrefix();
10-
const name = prefix + github.context.runId;
11-
await cache.saveCache([await common.getZigCachePath()], name);
10+
const cache_path = await common.getZigCachePath();
11+
12+
let accessible = true;
13+
try {
14+
await fs.access(cache_path, fs.constants.R_OK);
15+
} catch {
16+
accessible = false;
17+
}
18+
19+
if (accessible) {
20+
const prefix = await common.getCachePrefix();
21+
const name = prefix + github.context.runId;
22+
await cache.saveCache([cache_path], name);
23+
}
1224
}
1325
} catch (err) {
1426
core.setFailed(err.message);

0 commit comments

Comments
 (0)