Skip to content

Commit de2365a

Browse files
committed
opt to disable build record upload
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent bca5082 commit de2365a

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

.github/workflows/ci.yml

+23
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,29 @@ jobs:
14121412
with:
14131413
file: ./test/Dockerfile
14141414

1415+
record-upload-disable:
1416+
runs-on: ubuntu-latest
1417+
steps:
1418+
-
1419+
name: Checkout
1420+
uses: actions/checkout@v4
1421+
with:
1422+
path: action
1423+
-
1424+
name: Set up Docker Buildx
1425+
uses: docker/setup-buildx-action@v3
1426+
with:
1427+
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
1428+
driver-opts: |
1429+
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
1430+
-
1431+
name: Build
1432+
uses: ./action
1433+
with:
1434+
file: ./test/Dockerfile
1435+
env:
1436+
DOCKER_BUILD_RECORD_UPLOAD: false
1437+
14151438
export-retention-days:
14161439
runs-on: ubuntu-latest
14171440
strategy:

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ The following outputs are available:
259259
| Name | Type | Default | Description |
260260
|--------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
261261
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled |
262+
| `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 |
262263
| `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` |
263264

264265
## Troubleshooting

src/main.ts

+25-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {Util} from '@docker/actions-toolkit/lib/util';
1515

1616
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder';
1717
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
18+
import {UploadArtifactResponse} from '@docker/actions-toolkit/lib/types/github';
1819

1920
import * as context from './context';
2021

@@ -163,17 +164,27 @@ actionsToolkit.run(
163164
if (stateHelper.isSummarySupported) {
164165
await core.group(`Generating build summary`, async () => {
165166
try {
166-
const exportRetentionDays = buildExportRetentionDays();
167+
const recordUploadEnabled = buildRecordUploadEnabled();
168+
let exportRetentionDays: number | undefined;
169+
if (recordUploadEnabled) {
170+
exportRetentionDays = buildExportRetentionDays();
171+
}
172+
167173
const buildxHistory = new BuildxHistory();
168174
const exportRes = await buildxHistory.export({
169175
refs: stateHelper.buildRef ? [stateHelper.buildRef] : []
170176
});
171-
core.info(`Build record exported to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
172-
const uploadRes = await GitHub.uploadArtifact({
173-
filename: exportRes.dockerbuildFilename,
174-
mimeType: 'application/gzip',
175-
retentionDays: exportRetentionDays
176-
});
177+
core.info(`Build record written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
178+
179+
let uploadRes: UploadArtifactResponse | undefined;
180+
if (recordUploadEnabled) {
181+
uploadRes = await GitHub.uploadArtifact({
182+
filename: exportRes.dockerbuildFilename,
183+
mimeType: 'application/gzip',
184+
retentionDays: exportRetentionDays
185+
});
186+
}
187+
177188
await GitHub.writeBuildSummary({
178189
exportRes: exportRes,
179190
uploadRes: uploadRes,
@@ -221,6 +232,13 @@ function buildSummaryEnabled(): boolean {
221232
return true;
222233
}
223234

235+
function buildRecordUploadEnabled(): boolean {
236+
if (process.env.DOCKER_BUILD_RECORD_UPLOAD) {
237+
return Util.parseBool(process.env.DOCKER_BUILD_RECORD_UPLOAD);
238+
}
239+
return true;
240+
}
241+
224242
function buildExportRetentionDays(): number | undefined {
225243
if (process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS) {
226244
const res = parseInt(process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS);

0 commit comments

Comments
 (0)