Skip to content

Commit

Permalink
DOCKER_BUILD_EXPORT_LEGACY env var to opt-in for legacy export
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
  • Loading branch information
CrazyMax committed May 13, 2025
1 parent 721e8c7 commit db1f6c4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,35 @@ jobs:
env:
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}

export-legacy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
legacy:
- false
- true
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
path: action
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
driver-opts: |
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
-
name: Build
uses: ./action
with:
file: ./test/Dockerfile
env:
DOCKER_BUILD_EXPORT_LEGACY: ${{ matrix.legacy }}

checks:
runs-on: ubuntu-latest
strategy:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,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_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` |
| `DOCKER_BUILD_EXPORT_LEGACY` | Bool | `false` | If `true`, exports build using legacy export-build tool instead of [`buildx history export` command](https://docs.docker.com/reference/cli/docker/buildx/history/export/) |

## Troubleshooting

Expand Down
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ actionsToolkit.run(

const buildxHistory = new BuildxHistory();
const exportRes = await buildxHistory.export({
refs: stateHelper.buildRef ? [stateHelper.buildRef] : []
refs: stateHelper.buildRef ? [stateHelper.buildRef] : [],
useContainer: buildExportLegacy()
});
core.info(`Build record written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);

Expand Down Expand Up @@ -294,3 +295,10 @@ function buildRecordRetentionDays(): number | undefined {
return res;
}
}

function buildExportLegacy(): boolean {
if (process.env.DOCKER_BUILD_EXPORT_LEGACY) {
return Util.parseBool(process.env.DOCKER_BUILD_EXPORT_LEGACY);
}
return false;
}

0 comments on commit db1f6c4

Please sign in to comment.