src: only commit stickydisk in post step if in setup-only

Firstly this was a bug where we were trying to commit in the post
step even if we had already committed at the end of the main step in
a non-setup-only invocation.

Secondly, if the action is canceled before the exposeID is set in the main
process, we don't want to send a commit request with an empty exposeID.
This commit is contained in:
Claude 2025-04-29 17:01:42 -04:00
parent 5646913081
commit 296109dd1e
4 changed files with 23 additions and 6 deletions

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -226,6 +226,7 @@ actionsToolkit.run(
// If setup-only is true, we don't want to continue configuring and running the build.
if (inputs.setupOnly) {
core.info('setup-only mode enabled, builder is ready for use by Docker');
stateHelper.setSetupOnly(true);
// Let's remove the default
process.exit(0);
}
@ -511,9 +512,17 @@ actionsToolkit.run(
core.debug(`Removed temp folder ${stateHelper.tmpDir}`);
}
// 5. Commit sticky disk if it exists.
core.info('Committing sticky disk');
await reporter.commitStickyDisk(stateHelper.getExposeId());
// 5. Commit sticky disk if the builder was booted in setup-only mode.
// If the builder was not booted in setup-only mode, the sticky disk was committed as part
// of the main routine.
if (stateHelper.getSetupOnly()) {
core.info('Committing sticky disk in post cleanup as setup-only mode was enabled');
if (stateHelper.getExposeId() !== '') {
await reporter.commitStickyDisk(stateHelper.getExposeId());
} else {
core.warning('Expose ID not found in state, skipping sticky disk commit');
}
}
} catch (error) {
core.warning(`Error during final cleanup: ${error.message}`);
await reporter.reportBuildPushActionFailure(error, 'final cleanup');

View File

@ -65,4 +65,12 @@ export function setExposeId(exposeId: string) {
export function getExposeId(): string {
return core.getState('exposeId');
}
}
export function setSetupOnly(setupOnly: boolean) {
core.saveState('setupOnly', setupOnly.toString());
}
export function getSetupOnly(): boolean {
return core.getState('setupOnly') === 'true';
}