Skip to content

Commit

Permalink
add a bunch of info logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nonrational committed Feb 27, 2024
1 parent 9072567 commit f8e62aa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,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`)

Check failure on line 23 in src/index.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 23 in src/index.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

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

0 comments on commit f8e62aa

Please sign in to comment.