cache/save.js

29 lines
746 B
JavaScript

import { mounts, primaryKey, isExactKeyMatch } from './config'
import { info, error, getState } from '@actions/core'
import * as cache from "@actions/cache"
async function run() {
if (!cache.isFeatureAvailable()) {
error('缓存未启用')
return
}
const restoredKey = getState('cacheKey')
if (isExactKeyMatch(primaryKey, restoredKey)) {
info(
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
)
return
}
const cacheId = await cache.saveCache(
mounts,
primaryKey,
{ uploadChunkSize: 1024 * 1024 * 10 },
false
)
if (cacheId != -1) {
info(`Cache saved with key: ${primaryKey}`);
}
}
await run()