mirror of
https://github.com/docker/bake-action.git
synced 2026-01-22 12:22:21 +01:00
opt to disable build record upload
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
23
.github/workflows/ci.yml
vendored
23
.github/workflows/ci.yml
vendored
@@ -590,6 +590,29 @@ jobs:
|
|||||||
./test/config.hcl
|
./test/config.hcl
|
||||||
targets: app
|
targets: app
|
||||||
|
|
||||||
|
record-upload-disable:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
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: ./
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
targets: app
|
||||||
|
env:
|
||||||
|
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||||
|
|
||||||
export-retention-days:
|
export-retention-days:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ 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_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_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` |
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|||||||
24
src/main.ts
24
src/main.ts
@@ -15,6 +15,7 @@ import {Util} from '@docker/actions-toolkit/lib/util';
|
|||||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
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';
|
||||||
import * as stateHelper from './state-helper';
|
import * as stateHelper from './state-helper';
|
||||||
@@ -189,17 +190,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 exportRetentionDays: number | undefined;
|
||||||
|
if (recordUploadEnabled) {
|
||||||
|
exportRetentionDays = buildExportRetentionDays();
|
||||||
|
}
|
||||||
|
|
||||||
const buildxHistory = new BuildxHistory();
|
const buildxHistory = new BuildxHistory();
|
||||||
const exportRes = await buildxHistory.export({
|
const exportRes = await buildxHistory.export({
|
||||||
refs: stateHelper.buildRefs
|
refs: stateHelper.buildRefs
|
||||||
});
|
});
|
||||||
core.info(`Build records exported to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
core.info(`Build records written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
||||||
const uploadRes = await GitHub.uploadArtifact({
|
|
||||||
|
let uploadRes: UploadArtifactResponse | undefined;
|
||||||
|
if (recordUploadEnabled) {
|
||||||
|
uploadRes = await GitHub.uploadArtifact({
|
||||||
filename: exportRes.dockerbuildFilename,
|
filename: exportRes.dockerbuildFilename,
|
||||||
mimeType: 'application/gzip',
|
mimeType: 'application/gzip',
|
||||||
retentionDays: exportRetentionDays
|
retentionDays: exportRetentionDays
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await GitHub.writeBuildSummary({
|
await GitHub.writeBuildSummary({
|
||||||
exportRes: exportRes,
|
exportRes: exportRes,
|
||||||
uploadRes: uploadRes,
|
uploadRes: uploadRes,
|
||||||
@@ -254,6 +265,13 @@ function buildSummaryEnabled(): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildRecordUploadEnabled(): boolean {
|
||||||
|
if (process.env.DOCKER_BUILD_RECORD_UPLOAD) {
|
||||||
|
return Util.parseBool(process.env.DOCKER_BUILD_RECORD_UPLOAD);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function buildExportRetentionDays(): number | undefined {
|
function buildExportRetentionDays(): number | 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);
|
const res = parseInt(process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS);
|
||||||
|
|||||||
Reference in New Issue
Block a user