fix: reorganize post actions

This commit is contained in:
Simon BRICHE 2025-11-18 11:18:27 +01:00
parent bf9c5d876c
commit c7d4148a08
2 changed files with 12 additions and 9 deletions

View File

@ -13,6 +13,6 @@ export async function cleanPipPackages() {
]);
core.info('Successfully cleaned up pip packages');
} catch (error) {
core.setFailed(`Failed to clean up pip packages.`);
core.setFailed('Failed to clean up pip packages.');
}
}

View File

@ -11,8 +11,17 @@ import {State} from './cache-distributions/cache-distributor';
export async function run(earlyExit?: boolean) {
try {
const cache = core.getInput('cache');
if (cache) {
await saveCache(cache);
// Optionally clean up pip packages after the post-action if requested.
// This mirrors the `preclean` behavior used in the main action.
const postcleanPip = core.getBooleanInput('postclean');
if (cache || postcleanPip) {
if (cache) {
await saveCache(cache);
}
if (postcleanPip) {
await cleanPipPackages();
}
// Preserve early-exit behavior for the post action when requested.
// Some CI setups may want the post step to exit early to avoid long-running
// processes during cleanup. If enabled, exit with success immediately.
@ -20,12 +29,6 @@ export async function run(earlyExit?: boolean) {
process.exit(0);
}
}
// Optionally clean up pip packages after the post-action if requested.
// This mirrors the `preclean-pip` behavior used in the main action.
const postcleanPip = core.getBooleanInput('postclean');
if (postcleanPip) {
await cleanPipPackages();
}
} catch (error) {
const err = error as Error;
core.setFailed(err.message);