use default retention days for build export artifact

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-06-24 10:14:14 +02:00
parent 31159d49c0
commit 9cac6c8ea0
No known key found for this signature in database
GPG key ID: ADE44D8C9D44FBE4
3 changed files with 45 additions and 4 deletions

View file

@ -151,6 +151,7 @@ actionsToolkit.run(
return;
}
try {
const exportRetentionDays = buildExportRetentionDays();
const buildxHistory = new BuildxHistory();
const exportRes = await buildxHistory.export({
refs: [stateHelper.buildRef]
@ -159,7 +160,7 @@ actionsToolkit.run(
const uploadRes = await GitHub.uploadArtifact({
filename: exportRes.dockerbuildFilename,
mimeType: 'application/gzip',
retentionDays: 90
retentionDays: exportRetentionDays
});
await GitHub.writeBuildSummary({
exportRes: exportRes,
@ -197,3 +198,13 @@ async function buildRef(toolkit: Toolkit, since: Date, builder?: string): Promis
});
return Object.keys(refs).length > 0 ? Object.keys(refs)[0] : '';
}
function buildExportRetentionDays(): number | undefined {
if (process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS) {
const res = parseInt(process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS);
if (isNaN(res)) {
throw Error(`Invalid build export retention days: ${process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS}`);
}
return res;
}
}