Skip to content

Commit

Permalink
feat: improve logging
Browse files Browse the repository at this point in the history
Co-authored-by: hiraginoyuki <[email protected]>
  • Loading branch information
Mogyuchi and hiraginoyuki committed Jan 30, 2024
1 parent 1ed51fc commit 9e98e67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
17 changes: 9 additions & 8 deletions dist/index.js

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

17 changes: 9 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ const deleteRefActionsCaches = async (

// https://github.com/octokit/octokit.js/tree/b831b6bce43d56b97e25a996e1b43525486d8bd3?tab=readme-ov-file#pagination
for await (const { data: cacheList } of iterator) {
for (const { id: cacheId } of cacheList) {
if (!cacheId) continue
for (const cache of cacheList) {
if (!cache.id) continue
core.info(` - Cache with key ${cache.key}`)
await octokit.rest.actions.deleteActionsCacheById({
...repo,
cache_id: cacheId
cache_id: cache.id
})
}
}
Expand All @@ -44,21 +45,21 @@ export async function run(): Promise<void> {
const ref = getRef({ eventName, payload })

if (ref === null) {
core.info('Could not determine deletion target.')
core.info('🤔 Could not determine deletion target.')
core.info(
'If you suspect this is a bug, please consider raising an issue to help us address it promptly.'
'ℹ️ If you suspect this is a bug, please consider raising an issue to help us address it promptly.'
)
return
}
core.info(`Delete cache for ${ref}`)
core.info(`⌛ Deleting caches on ${ref}`)
await deleteRefActionsCaches(octokit, repo, ref)
core.info('Done ✅')
core.info('✅ Done')
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) {
core.setFailed(error.message)
core.info(
'If you suspect this is a bug, please consider raising an issue to help us address it promptly.'
'ℹ️ If you suspect this is a bug, please consider raising an issue to help us address it promptly.'
)
}
}
Expand Down

0 comments on commit 9e98e67

Please sign in to comment.