Merge pull request #1172 from crazy-max/build-export-disable
opt to disable build record uploadpull/1174/head v6.3.0
commit
1a162644f9
|
@ -1412,7 +1412,30 @@ jobs:
|
|||
with:
|
||||
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
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
@ -1439,4 +1462,4 @@ jobs:
|
|||
with:
|
||||
file: ./test/Dockerfile
|
||||
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 |
|
||||
|--------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `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
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
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 {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker';
|
||||
import {UploadArtifactResponse} from '@docker/actions-toolkit/lib/types/github';
|
||||
|
||||
import * as context from './context';
|
||||
|
||||
|
@ -163,17 +164,27 @@ actionsToolkit.run(
|
|||
if (stateHelper.isSummarySupported) {
|
||||
await core.group(`Generating build summary`, async () => {
|
||||
try {
|
||||
const exportRetentionDays = buildExportRetentionDays();
|
||||
const recordUploadEnabled = buildRecordUploadEnabled();
|
||||
let recordRetentionDays: number | undefined;
|
||||
if (recordUploadEnabled) {
|
||||
recordRetentionDays = buildRecordRetentionDays();
|
||||
}
|
||||
|
||||
const buildxHistory = new BuildxHistory();
|
||||
const exportRes = await buildxHistory.export({
|
||||
refs: stateHelper.buildRef ? [stateHelper.buildRef] : []
|
||||
});
|
||||
core.info(`Build record exported to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
||||
const uploadRes = await GitHub.uploadArtifact({
|
||||
filename: exportRes.dockerbuildFilename,
|
||||
mimeType: 'application/gzip',
|
||||
retentionDays: exportRetentionDays
|
||||
});
|
||||
core.info(`Build record written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
||||
|
||||
let uploadRes: UploadArtifactResponse | undefined;
|
||||
if (recordUploadEnabled) {
|
||||
uploadRes = await GitHub.uploadArtifact({
|
||||
filename: exportRes.dockerbuildFilename,
|
||||
mimeType: 'application/gzip',
|
||||
retentionDays: recordRetentionDays
|
||||
});
|
||||
}
|
||||
|
||||
await GitHub.writeBuildSummary({
|
||||
exportRes: exportRes,
|
||||
uploadRes: uploadRes,
|
||||
|
@ -221,11 +232,25 @@ function buildSummaryEnabled(): boolean {
|
|||
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) {
|
||||
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)) {
|
||||
throw Error(`Invalid build export retention days: ${process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS}`);
|
||||
throw Error(`Invalid build record retention days: ${val}`);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue