From a67e68dc5c8281d9608136d3d7ca1b282213e4ac Mon Sep 17 00:00:00 2001 From: mlugg Date: Wed, 18 Sep 2024 16:14:29 +0100 Subject: [PATCH] Don't cache non-existent Zig cache directory --- post.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/post.js b/post.js index 96bcab8..6aecd4d 100644 --- a/post.js +++ b/post.js @@ -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);