mirror of
https://github.com/docker/build-push-action.git
synced 2026-07-06 08:20:04 +00:00
Compare commits
No commits in common. "1a162644f9a7e87d8f4b053101d1d9a712edc18c" and "709dde20a75aba6bd906ba678ec126ca1d2ff835" have entirely different histories.
1a162644f9
...
709dde20a7
50
.github/workflows/ci.yml
vendored
50
.github/workflows/ci.yml
vendored
@ -1346,29 +1346,6 @@ jobs:
|
|||||||
docker image inspect localhost:5000/name/app:latest
|
docker image inspect localhost:5000/name/app:latest
|
||||||
|
|
||||||
summary-disable:
|
summary-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_SUMMARY: false
|
|
||||||
|
|
||||||
summary-disable-deprecated:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
@ -1412,30 +1389,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
|
|
||||||
record-upload-disable:
|
export-retention-days:
|
||||||
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
|
||||||
@ -1462,4 +1416,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
env:
|
env:
|
||||||
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
|
DOCKER_BUILD_EXPORT_RETENTION_DAYS: ${{ matrix.days }}
|
||||||
|
|||||||
11
README.md
11
README.md
@ -186,7 +186,7 @@ more. The build record can be imported to Docker Desktop for inspecting the
|
|||||||
build in greater detail.
|
build in greater detail.
|
||||||
|
|
||||||
Summaries are enabled by default, but can be disabled with the
|
Summaries are enabled by default, but can be disabled with the
|
||||||
`DOCKER_BUILD_SUMMARY` [environment variable](#environment-variables).
|
`DOCKER_BUILD_NO_SUMMARY` [environment variable](#environment-variables).
|
||||||
|
|
||||||
For more information about summaries, refer to the
|
For more information about summaries, refer to the
|
||||||
[documentation](https://docs.docker.com/go/build-summary/).
|
[documentation](https://docs.docker.com/go/build-summary/).
|
||||||
@ -256,11 +256,10 @@ The following outputs are available:
|
|||||||
|
|
||||||
### environment variables
|
### environment variables
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | 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_NO_SUMMARY` | Bool | If `true`, [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_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
@ -27,7 +27,7 @@
|
|||||||
"packageManager": "yarn@3.6.3",
|
"packageManager": "yarn@3.6.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
"@docker/actions-toolkit": "0.31.0",
|
"@docker/actions-toolkit": "0.30.0",
|
||||||
"handlebars": "^4.7.7"
|
"handlebars": "^4.7.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
57
src/main.ts
57
src/main.ts
@ -15,7 +15,6 @@ 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';
|
||||||
|
|
||||||
@ -139,7 +138,7 @@ actionsToolkit.run(
|
|||||||
});
|
});
|
||||||
|
|
||||||
await core.group(`Check build summary support`, async () => {
|
await core.group(`Check build summary support`, async () => {
|
||||||
if (!buildSummaryEnabled()) {
|
if (process.env.DOCKER_BUILD_NO_SUMMARY && Util.parseBool(process.env.DOCKER_BUILD_NO_SUMMARY)) {
|
||||||
core.info('Build summary disabled');
|
core.info('Build summary disabled');
|
||||||
} else if (GitHub.isGHES) {
|
} else if (GitHub.isGHES) {
|
||||||
core.warning('Build summary is not yet supported on GHES');
|
core.warning('Build summary is not yet supported on GHES');
|
||||||
@ -164,27 +163,17 @@ 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 recordUploadEnabled = buildRecordUploadEnabled();
|
const exportRetentionDays = buildExportRetentionDays();
|
||||||
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 written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
core.info(`Build record exported to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
|
||||||
|
const uploadRes = await GitHub.uploadArtifact({
|
||||||
let uploadRes: UploadArtifactResponse | undefined;
|
filename: exportRes.dockerbuildFilename,
|
||||||
if (recordUploadEnabled) {
|
mimeType: 'application/gzip',
|
||||||
uploadRes = await GitHub.uploadArtifact({
|
retentionDays: exportRetentionDays
|
||||||
filename: exportRes.dockerbuildFilename,
|
});
|
||||||
mimeType: 'application/gzip',
|
|
||||||
retentionDays: recordRetentionDays
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await GitHub.writeBuildSummary({
|
await GitHub.writeBuildSummary({
|
||||||
exportRes: exportRes,
|
exportRes: exportRes,
|
||||||
uploadRes: uploadRes,
|
uploadRes: uploadRes,
|
||||||
@ -222,35 +211,11 @@ async function buildRef(toolkit: Toolkit, since: Date, builder?: string): Promis
|
|||||||
return Object.keys(refs).length > 0 ? Object.keys(refs)[0] : '';
|
return Object.keys(refs).length > 0 ? Object.keys(refs)[0] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildSummaryEnabled(): boolean {
|
function buildExportRetentionDays(): number | undefined {
|
||||||
if (process.env.DOCKER_BUILD_NO_SUMMARY) {
|
|
||||||
core.warning('DOCKER_BUILD_NO_SUMMARY is deprecated. Set DOCKER_BUILD_SUMMARY to false instead.');
|
|
||||||
return !Util.parseBool(process.env.DOCKER_BUILD_NO_SUMMARY);
|
|
||||||
} else if (process.env.DOCKER_BUILD_SUMMARY) {
|
|
||||||
return Util.parseBool(process.env.DOCKER_BUILD_SUMMARY);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
core.warning('DOCKER_BUILD_EXPORT_RETENTION_DAYS is deprecated. Use DOCKER_BUILD_RECORD_RETENTION_DAYS instead.');
|
const res = parseInt(process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS);
|
||||||
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 record retention days: ${val}`);
|
throw Error(`Invalid build export retention days: ${process.env.DOCKER_BUILD_EXPORT_RETENTION_DAYS}`);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
10
yarn.lock
10
yarn.lock
@ -1055,9 +1055,9 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@docker/actions-toolkit@npm:0.31.0":
|
"@docker/actions-toolkit@npm:0.30.0":
|
||||||
version: 0.31.0
|
version: 0.30.0
|
||||||
resolution: "@docker/actions-toolkit@npm:0.31.0"
|
resolution: "@docker/actions-toolkit@npm:0.30.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@actions/artifact": ^2.1.7
|
"@actions/artifact": ^2.1.7
|
||||||
"@actions/cache": ^3.2.4
|
"@actions/cache": ^3.2.4
|
||||||
@ -1080,7 +1080,7 @@ __metadata:
|
|||||||
semver: ^7.6.2
|
semver: ^7.6.2
|
||||||
tar-stream: ^3.1.7
|
tar-stream: ^3.1.7
|
||||||
tmp: ^0.2.3
|
tmp: ^0.2.3
|
||||||
checksum: 34fdc08b6380bbee05fc740b161bb1172658da6d3e58f0f9cf8bc12011da638b37314e2a92a689542955189459ace241769c9f247a6917bf8365bc461221eecd
|
checksum: 0e5ea396c93558b4f9841485c57094a707a98cbbc4ade0de119fdf30dc4c3c7fbb0a5ed86d187f89d78db03f66ea5c6903f241d5ca87c9a0f780ae868f866310
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -3150,7 +3150,7 @@ __metadata:
|
|||||||
resolution: "docker-build-push@workspace:."
|
resolution: "docker-build-push@workspace:."
|
||||||
dependencies:
|
dependencies:
|
||||||
"@actions/core": ^1.10.1
|
"@actions/core": ^1.10.1
|
||||||
"@docker/actions-toolkit": 0.31.0
|
"@docker/actions-toolkit": 0.30.0
|
||||||
"@types/node": ^20.12.12
|
"@types/node": ^20.12.12
|
||||||
"@typescript-eslint/eslint-plugin": ^7.9.0
|
"@typescript-eslint/eslint-plugin": ^7.9.0
|
||||||
"@typescript-eslint/parser": ^7.9.0
|
"@typescript-eslint/parser": ^7.9.0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user