Skip to content

Commit db1f6c4

Browse files
committed
DOCKER_BUILD_EXPORT_LEGACY env var to opt-in for legacy export
Signed-off-by: CrazyMax <[email protected]>
1 parent 721e8c7 commit db1f6c4

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,35 @@ jobs:
14641464
env:
14651465
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
14661466

1467+
export-legacy:
1468+
runs-on: ubuntu-latest
1469+
strategy:
1470+
fail-fast: false
1471+
matrix:
1472+
legacy:
1473+
- false
1474+
- true
1475+
steps:
1476+
-
1477+
name: Checkout
1478+
uses: actions/checkout@v4
1479+
with:
1480+
path: action
1481+
-
1482+
name: Set up Docker Buildx
1483+
uses: docker/setup-buildx-action@v3
1484+
with:
1485+
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
1486+
driver-opts: |
1487+
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
1488+
-
1489+
name: Build
1490+
uses: ./action
1491+
with:
1492+
file: ./test/Dockerfile
1493+
env:
1494+
DOCKER_BUILD_EXPORT_LEGACY: ${{ matrix.legacy }}
1495+
14671496
checks:
14681497
runs-on: ubuntu-latest
14691498
strategy:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ The following outputs are available:
277277
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled |
278278
| `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 |
279279
| `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` |
280+
| `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/) |
280281

281282
## Troubleshooting
282283

src/main.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ actionsToolkit.run(
200200

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

@@ -294,3 +295,10 @@ function buildRecordRetentionDays(): number | undefined {
294295
return res;
295296
}
296297
}
298+
299+
function buildExportLegacy(): boolean {
300+
if (process.env.DOCKER_BUILD_EXPORT_LEGACY) {
301+
return Util.parseBool(process.env.DOCKER_BUILD_EXPORT_LEGACY);
302+
}
303+
return false;
304+
}

0 commit comments

Comments
 (0)