mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-22 10:05:39 +01:00
Merge pull request #1172 from crazy-max/build-export-disable
opt to disable build record upload
This commit is contained in:
commit
1a162644f9
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
@ -1412,7 +1412,30 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
|
|
||||||
export-retention-days:
|
record-upload-disable:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
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_RECORD_UPLOAD: false
|
||||||
|
|
||||||
|
record-retention-days:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@ -1439,4 +1462,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
env:
|
env:
|
||||||
DOCKER_BUILD_EXPORT_RETENTION_DAYS: ${{ matrix.days }}
|
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
|
||||||
|
@ -259,7 +259,8 @@ The following outputs are available:
|
|||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|--------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|--------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled |
|
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation 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_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` |
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
18
dist/index.js
generated
vendored
18
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
45
src/main.ts
45
src/main.ts
@ -15,6 +15,7 @@ import {Util} from '@docker/actions-toolkit/lib/util';
|
|||||||
|
|
||||||
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder';
|
||||||
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
|
import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
|
||||||
|
import {UploadArtifactResponse} from '@docker/actions-toolkit/lib/types/github';
|
||||||
|
|
||||||
import * as context from './context';
|
import * as context from './context';
|
||||||
|
|
||||||
@ -163,17 +164,27 @@ actionsToolkit.run(
|
|||||||
if (stateHelper.isSummarySupported) {
|
if (stateHelper.isSummarySupported) {
|
||||||
await core.group(`Generating build summary`, async () => {
|
await core.group(`Generating build summary`, async () => {
|
||||||
try {
|
try {
|
||||||
const exportRetentionDays = buildExportRetentionDays();
|
const recordUploadEnabled = buildRecordUploadEnabled();
|
||||||
|
let recordRetentionDays: number | undefined;
|
||||||
|
if (recordUploadEnabled) {
|
||||||
|
recordRetentionDays = buildRecordRetentionDays();
|
||||||
|
}
|
||||||
|
|
||||||
const buildxHistory = new BuildxHistory();
|
const buildxHistory = new BuildxHistory();
|
||||||
const exportRes = await buildxHistory.export({
|
const exportRes = await buildxHistory.export({
|
||||||
refs: stateHelper.buildRef ? [stateHelper.buildRef] : []
|
refs: stateHelper.buildRef ? [stateHelper.buildRef] : []
|
||||||
});
|
});
|
||||||
core.info(`Build record exported to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
core.info(`Build record written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
||||||
const uploadRes = await GitHub.uploadArtifact({
|
|
||||||
filename: exportRes.dockerbuildFilename,
|
let uploadRes: UploadArtifactResponse | undefined;
|
||||||
mimeType: 'application/gzip',
|
if (recordUploadEnabled) {
|
||||||
retentionDays: exportRetentionDays
|
uploadRes = await GitHub.uploadArtifact({
|
||||||
});
|
filename: exportRes.dockerbuildFilename,
|
||||||
|
mimeType: 'application/gzip',
|
||||||
|
retentionDays: recordRetentionDays
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await GitHub.writeBuildSummary({
|
await GitHub.writeBuildSummary({
|
||||||
exportRes: exportRes,
|
exportRes: exportRes,
|
||||||
uploadRes: uploadRes,
|
uploadRes: uploadRes,
|
||||||
@ -221,11 +232,25 @@ function buildSummaryEnabled(): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildExportRetentionDays(): number | undefined {
|
function buildRecordUploadEnabled(): boolean {
|
||||||
|
if (process.env.DOCKER_BUILD_RECORD_UPLOAD) {
|
||||||
|
return Util.parseBool(process.env.DOCKER_BUILD_RECORD_UPLOAD);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRecordRetentionDays(): number | undefined {
|
||||||
|
let val: string | undefined;
|
||||||
if (process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS) {
|
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)) {
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user