From 11c2faaa9eaca329b60ac7e06d5b0a39bb83ceee Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:09:36 +0200 Subject: [PATCH] rename DOCKER_BUILD_EXPORT_RETENTION_DAYS to DOCKER_BUILD_RECORD_RETENTION_DAYS Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- README.md | 2 +- src/main.ts | 19 +++++++++++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc0a46a..5d32ecb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1435,7 +1435,7 @@ jobs: env: DOCKER_BUILD_RECORD_UPLOAD: false - export-retention-days: + record-retention-days: runs-on: ubuntu-latest strategy: fail-fast: false @@ -1462,4 +1462,4 @@ jobs: with: file: ./test/Dockerfile env: - DOCKER_BUILD_EXPORT_RETENTION_DAYS: ${{ matrix.days }} + DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }} diff --git a/README.md b/README.md index 77c0ef3..0fa5df2 100644 --- a/README.md +++ b/README.md @@ -260,7 +260,7 @@ The following outputs are available: |--------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled | | `DOCKER_BUILD_RECORD_UPLOAD` | Bool | `true` | If `false`, build record upload as [GitHub artifact](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) is disabled | -| `DOCKER_BUILD_EXPORT_RETENTION_DAYS` | Number | | Duration after which build export artifact will expire in days. Defaults to repository/org [retention settings](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy) if unset or `0` | +| `DOCKER_BUILD_RECORD_RETENTION_DAYS` | Number | | Duration after which build record artifact will expire in days. Defaults to repository/org [retention settings](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy) if unset or `0` | ## Troubleshooting diff --git a/src/main.ts b/src/main.ts index 5e91d69..d1e55f4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -165,9 +165,9 @@ actionsToolkit.run( await core.group(`Generating build summary`, async () => { try { const recordUploadEnabled = buildRecordUploadEnabled(); - let exportRetentionDays: number | undefined; + let recordRetentionDays: number | undefined; if (recordUploadEnabled) { - exportRetentionDays = buildExportRetentionDays(); + recordRetentionDays = buildRecordRetentionDays(); } const buildxHistory = new BuildxHistory(); @@ -181,7 +181,7 @@ actionsToolkit.run( uploadRes = await GitHub.uploadArtifact({ filename: exportRes.dockerbuildFilename, mimeType: 'application/gzip', - retentionDays: exportRetentionDays + retentionDays: recordRetentionDays }); } @@ -239,11 +239,18 @@ function buildRecordUploadEnabled(): boolean { return true; } -function buildExportRetentionDays(): number | undefined { +function buildRecordRetentionDays(): number | undefined { + let val: string | undefined; if (process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS) { - const res = parseInt(process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS); + core.warning('DOCKER_BUILD_EXPORT_RETENTION_DAYS is deprecated. Use DOCKER_BUILD_RECORD_RETENTION_DAYS instead.'); + val = process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS; + } else if (process.env.DOCKER_BUILD_RECORD_RETENTION_DAYS) { + val = process.env.DOCKER_BUILD_RECORD_RETENTION_DAYS; + } + if (val) { + const res = parseInt(val); if (isNaN(res)) { - throw Error(`Invalid build export retention days: ${process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS}`); + throw Error(`Invalid build record retention days: ${val}`); } return res; }