32 lines
786 B
JavaScript
32 lines
786 B
JavaScript
import { mounts, primaryKey, restoreKeys, isExactKeyMatch } from './config'
|
|
import { setOutput, info, error, saveState } from '@actions/core'
|
|
import * as cache from '@actions/cache'
|
|
|
|
async function run() {
|
|
if (!cache.isFeatureAvailable()) {
|
|
error('缓存未启用')
|
|
return
|
|
}
|
|
const cacheKey = await cache.restoreCache(
|
|
mounts,
|
|
primaryKey,
|
|
restoreKeys,
|
|
{ lookupOnly: false },
|
|
false
|
|
)
|
|
if (!cacheKey) {
|
|
info(
|
|
`Cache not found for input keys: ${[
|
|
primaryKey,
|
|
...restoreKeys,
|
|
].join(", ")}`
|
|
)
|
|
return
|
|
}
|
|
|
|
saveState('cacheKey', cacheKey)
|
|
|
|
setOutput('cache_init', isExactKeyMatch(primaryKey, cacheKey).toString())
|
|
}
|
|
|
|
await run() |