Skip to content

Commit

Permalink
npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
nonrational committed Feb 27, 2024
1 parent f8e62aa commit 5f55b34
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.9.0
9 changes: 8 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61981,23 +61981,30 @@ const run = async () => {
const cacheGroup = core.getInput('cache-group')
const keyPrefix = `cache-result-action-${cacheGroup}-${sha}`
const key = keyPrefix + '-' + Math.floor(Date.now() / 1000)

core.info(`Restoring cache '${key}' to '${RESULT_PATH}'`)

await cache.restoreCache([RESULT_PATH], key, [keyPrefix])

core.info(`Finished restore cache`)

let actualResult = inputResult

// True if we have a previous result already.
const cacheHit = !!fs.existsSync(RESULT_PATH)

let cacheOutcome = cacheHit ? 'hit' : 'miss'

// If the result is 'unknown' then we won't save it to the cache; we're in "restore only" mode.
if (inputResult !== 'unknown') {
core.info('Writing result to file and cache')
fs.writeFileSync(RESULT_PATH, inputResult)
await cache.saveCache([RESULT_PATH], key)
cacheOutcome = 'write'
core.info(`Wrote result to cache '${RESULT_PATH}' with key '${key}'`)
} else if (cacheHit) {
core.info(`Reading result from '${RESULT_PATH}'`)
actualResult = fs.readFileSync(RESULT_PATH, { encoding: 'utf8' })
core.info(`Read result '${actualResult}'`)
}

core.setOutput('result', actualResult)
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5f55b34

Please sign in to comment.