Skip to content

Commit

Permalink
Don't cache non-existent Zig cache directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mlugg committed Sep 18, 2024
1 parent e37757d commit a67e68d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions post.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs').promises;
const core = require('@actions/core');
const github = require('@actions/github');
const cache = require('@actions/cache');
Expand All @@ -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);
Expand Down

0 comments on commit a67e68d

Please sign in to comment.