fix: skip saving missing cache directories

This commit is contained in:
Zoltan Kochan
2026-11-03 11:47:50 +01:00
parent 7cf8c4cab0
commit eedd901dbd
4 changed files with 173 additions and 113 deletions
+12
View File
@@ -1,5 +1,6 @@
import { saveCache } from '@actions/cache'
import { getState, info } from '@actions/core'
import { access } from 'fs/promises'
export async function runSaveCache() {
const state = getState('cache_restored_key')
@@ -11,6 +12,17 @@ export async function runSaveCache() {
return
}
try {
await access(cachePath)
} catch (error) {
if (!(error instanceof Error)) throw error
if (!('code' in error)) throw error
if (error.code !== 'ENOENT') throw error
info(`Cache path ${cachePath} does not exist, not saving cache.`)
return
}
const cacheId = await saveCache([cachePath], primaryKey)
if (cacheId == -1) return