diff --git a/src/action/main.ts b/src/action/main.ts index 5893c7bc..3d98bdab 100644 --- a/src/action/main.ts +++ b/src/action/main.ts @@ -76,16 +76,16 @@ async function run(): Promise { '--disable-sandbox', inputs.steward.extraArgs?.value.split(' ') ?? [], ], inputs.steward.extraJars) - } finally { - await workspace.saveWorkspaceCache() - await workspace.cancelTokenRefresh() - } - if (files.existsSync(workspace.runSummary_md)) { - logger.info(`✓ Run Summary file: ${workspace.runSummary_md}`) + if (files.existsSync(workspace.runSummary_md)) { + logger.info(`✓ Run Summary file: ${workspace.runSummary_md}`) - const summaryMarkdown = files.readFileSync(workspace.runSummary_md, 'utf8') - await core.summary.addRaw(summaryMarkdown).write() + const summaryMarkdown = files.readFileSync(workspace.runSummary_md, 'utf8') + await core.summary.addRaw(summaryMarkdown).write() + } + } finally { + await workspace.purgeTempFilesAndSaveCache() + await workspace.cancelTokenRefresh() } } catch (error: unknown) { core.setFailed(` ✕ ${(error as Error).message}`) diff --git a/src/modules/workspace.test.ts b/src/modules/workspace.test.ts index b2f072a8..b47364c5 100644 --- a/src/modules/workspace.test.ts +++ b/src/modules/workspace.test.ts @@ -187,7 +187,7 @@ test('`Workspace.restoreWorkspaceCache()` → generates different hash for diffe test('`Workspace.saveWorkspaceCache()` → saves cache', async t => { const {workspace, calls} = fixture('- owner/repo') - await workspace.saveWorkspaceCache() + await workspace.purgeTempFilesAndSaveCache() const now = Date.now() diff --git a/src/modules/workspace.ts b/src/modules/workspace.ts index 917aacd0..f79b0c62 100644 --- a/src/modules/workspace.ts +++ b/src/modules/workspace.ts @@ -74,7 +74,7 @@ export class Workspace { * * @param {string} workspace - the Scala Steward workspace directory */ - async saveWorkspaceCache(): Promise { + async purgeTempFilesAndSaveCache(): Promise { try { this.logger.startGroup('Saving workspace to cache...')