mirror of
https://github.com/docker/build-push-action.git
synced 2025-04-19 18:06:46 +00:00
use default retention days for build export artifact
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
31159d49c0
commit
9cac6c8ea0
3 changed files with 45 additions and 4 deletions
13
src/main.ts
13
src/main.ts
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue