mirror of
https://github.com/docker/build-push-action.git
synced 2025-06-13 14:47:13 +02:00
Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
4f58ea7922 | |||
49b5ea61c6 | |||
13c9fddd72 | |||
e44afff359 | |||
67ebad331f | |||
32945a3392 | |||
e0fe9cf0f2 | |||
8f1ff6bf9a | |||
5cd11c3a4c | |||
0aba704831 | |||
23c657a01f | |||
16ebe778df | |||
646a62b4f2 | |||
d92ab1347f | |||
4f7cdeb0f0 | |||
ad3cd774a4 | |||
3efbc13366 | |||
2dbe91db48 | |||
7de3854c4c | |||
175aa53a3f | |||
806a2a461f | |||
a8d35412fb | |||
1672e74297 | |||
a04f51d3b4 |
48
.github/workflows/ci.yml
vendored
48
.github/workflows/ci.yml
vendored
@ -1463,3 +1463,51 @@ jobs:
|
||||
file: ./test/Dockerfile
|
||||
env:
|
||||
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
|
||||
|
||||
checks:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
buildx-version:
|
||||
- latest
|
||||
- v0.14.1
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
version: ${{ matrix.buildx-version }}
|
||||
driver-opts: |
|
||||
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||
-
|
||||
name: Build
|
||||
uses: ./
|
||||
with:
|
||||
context: ./test
|
||||
file: ./test/lint.Dockerfile
|
||||
|
||||
annotations-disabled:
|
||||
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:
|
||||
context: ./test
|
||||
file: ./test/lint.Dockerfile
|
||||
env:
|
||||
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
|
||||
|
@ -258,6 +258,7 @@ The following outputs are available:
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|--------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `DOCKER_BUILD_CHECKS_ANNOTATIONS` | Bool | `true` | If `false`, GitHub annotations are not generated for [build checks](https://docs.docker.com/build/checks/) |
|
||||
| `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_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` |
|
||||
|
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",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
"@docker/actions-toolkit": "0.35.0",
|
||||
"@docker/actions-toolkit": "0.39.0",
|
||||
"handlebars": "^4.7.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
41
src/main.ts
41
src/main.ts
@ -97,7 +97,12 @@ actionsToolkit.run(
|
||||
|
||||
let err: Error | undefined;
|
||||
await Exec.getExecOutput(buildCmd.command, buildCmd.args, {
|
||||
ignoreReturnCode: true
|
||||
ignoreReturnCode: true,
|
||||
env: Object.assign({}, process.env, {
|
||||
BUILDX_METADATA_WARNINGS: 'true'
|
||||
}) as {
|
||||
[key: string]: string;
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||
@ -106,7 +111,7 @@ actionsToolkit.run(
|
||||
|
||||
const imageID = toolkit.buildxBuild.resolveImageID();
|
||||
const metadata = toolkit.buildxBuild.resolveMetadata();
|
||||
const digest = toolkit.buildxBuild.resolveDigest();
|
||||
const digest = toolkit.buildxBuild.resolveDigest(metadata);
|
||||
if (imageID) {
|
||||
await core.group(`ImageID`, async () => {
|
||||
core.info(imageID);
|
||||
@ -127,7 +132,7 @@ actionsToolkit.run(
|
||||
});
|
||||
}
|
||||
|
||||
let ref: string;
|
||||
let ref: string | undefined;
|
||||
await core.group(`Reference`, async () => {
|
||||
ref = await buildRef(toolkit, startedTime, inputs.builder);
|
||||
if (ref) {
|
||||
@ -138,17 +143,32 @@ actionsToolkit.run(
|
||||
}
|
||||
});
|
||||
|
||||
if (buildChecksAnnotationsEnabled()) {
|
||||
const warnings = toolkit.buildxBuild.resolveWarnings(metadata);
|
||||
if (ref && warnings && warnings.length > 0) {
|
||||
const annotations = await Buildx.convertWarningsToGitHubAnnotations(warnings, [ref]);
|
||||
core.debug(`annotations: ${JSON.stringify(annotations, null, 2)}`);
|
||||
if (annotations && annotations.length > 0) {
|
||||
await core.group(`Generating GitHub annotations (${annotations.length} build checks found)`, async () => {
|
||||
for (const annotation of annotations) {
|
||||
core.warning(annotation.message, annotation);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await core.group(`Check build summary support`, async () => {
|
||||
if (!buildSummaryEnabled()) {
|
||||
core.info('Build summary disabled');
|
||||
} else if (GitHub.isGHES) {
|
||||
core.warning('Build summary is not yet supported on GHES');
|
||||
core.info('Build summary is not yet supported on GHES');
|
||||
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
|
||||
core.warning('Build summary requires Buildx >= 0.13.0');
|
||||
core.info('Build summary requires Buildx >= 0.13.0');
|
||||
} else if (builder && builder.driver === 'cloud') {
|
||||
core.warning('Build summary is not yet supported with Docker Build Cloud');
|
||||
core.info('Build summary is not yet supported with Docker Build Cloud');
|
||||
} else if (!ref) {
|
||||
core.warning('Build summary requires a build reference');
|
||||
core.info('Build summary requires a build reference');
|
||||
} else {
|
||||
core.info('Build summary supported!');
|
||||
stateHelper.setSummarySupported();
|
||||
@ -222,6 +242,13 @@ async function buildRef(toolkit: Toolkit, since: Date, builder?: string): Promis
|
||||
return Object.keys(refs).length > 0 ? Object.keys(refs)[0] : '';
|
||||
}
|
||||
|
||||
function buildChecksAnnotationsEnabled(): boolean {
|
||||
if (process.env.DOCKER_BUILD_CHECKS_ANNOTATIONS) {
|
||||
return Util.parseBool(process.env.DOCKER_BUILD_CHECKS_ANNOTATIONS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function buildSummaryEnabled(): boolean {
|
||||
if (process.env.DOCKER_BUILD_NO_SUMMARY) {
|
||||
core.warning('DOCKER_BUILD_NO_SUMMARY is deprecated. Set DOCKER_BUILD_SUMMARY to false instead.');
|
||||
|
12
test/lint.Dockerfile
Normal file
12
test/lint.Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
frOM busybox as base
|
||||
cOpy lint.Dockerfile .
|
||||
|
||||
from scratch
|
||||
MAINTAINER moby@example.com
|
||||
COPy --from=base \
|
||||
/lint.Dockerfile \
|
||||
/
|
||||
|
||||
CMD [ "echo", "Hello, Norway!" ]
|
||||
CMD [ "echo", "Hello, Sweden!" ]
|
||||
ENTRYPOINT my-program start
|
40
yarn.lock
40
yarn.lock
@ -12,9 +12,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@actions/artifact@npm:^2.1.8":
|
||||
version: 2.1.8
|
||||
resolution: "@actions/artifact@npm:2.1.8"
|
||||
"@actions/artifact@npm:^2.1.9":
|
||||
version: 2.1.9
|
||||
resolution: "@actions/artifact@npm:2.1.9"
|
||||
dependencies:
|
||||
"@actions/core": ^1.10.0
|
||||
"@actions/github": ^5.1.1
|
||||
@ -30,7 +30,7 @@ __metadata:
|
||||
jwt-decode: ^3.1.2
|
||||
twirp-ts: ^2.5.0
|
||||
unzip-stream: ^0.3.1
|
||||
checksum: 51a47c21bcdac705abb61dbaef923f2760354c39bcad44a31b129e18bf31f646e5148f92ee7e1198275d1dba7bebfd1d1500ad7f62f6de1e65b57b2d092d5341
|
||||
checksum: b01404aa6b4d47186e04a64c0002100ff68a8473eafb811a3d49275a7e1135d1981ccaf527b81c4856f6da764beabe7489fd296bb287906fd7c1964dfaeef3df
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -105,7 +105,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@actions/http-client@npm:^2.0.1, @actions/http-client@npm:^2.1.0, @actions/http-client@npm:^2.1.1, @actions/http-client@npm:^2.2.0, @actions/http-client@npm:^2.2.1":
|
||||
"@actions/http-client@npm:^2.0.1, @actions/http-client@npm:^2.1.0, @actions/http-client@npm:^2.1.1, @actions/http-client@npm:^2.2.0":
|
||||
version: 2.2.1
|
||||
resolution: "@actions/http-client@npm:2.2.1"
|
||||
dependencies:
|
||||
@ -115,6 +115,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@actions/http-client@npm:^2.2.3":
|
||||
version: 2.2.3
|
||||
resolution: "@actions/http-client@npm:2.2.3"
|
||||
dependencies:
|
||||
tunnel: ^0.0.6
|
||||
undici: ^5.25.4
|
||||
checksum: 5d395df575d30ae599efa10dd715e72944b015e753db61f0a823f737acbb0e99743d4a9f25e812b18ec8cc34f86c73565d075c449e01ffa891577b6595212dde
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@actions/io@npm:^1.0.1, @actions/io@npm:^1.1.1, @actions/io@npm:^1.1.3":
|
||||
version: 1.1.3
|
||||
resolution: "@actions/io@npm:1.1.3"
|
||||
@ -1055,16 +1065,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@docker/actions-toolkit@npm:0.35.0":
|
||||
version: 0.35.0
|
||||
resolution: "@docker/actions-toolkit@npm:0.35.0"
|
||||
"@docker/actions-toolkit@npm:0.39.0":
|
||||
version: 0.39.0
|
||||
resolution: "@docker/actions-toolkit@npm:0.39.0"
|
||||
dependencies:
|
||||
"@actions/artifact": ^2.1.8
|
||||
"@actions/artifact": ^2.1.9
|
||||
"@actions/cache": ^3.2.4
|
||||
"@actions/core": ^1.10.1
|
||||
"@actions/exec": ^1.1.1
|
||||
"@actions/github": ^6.0.0
|
||||
"@actions/http-client": ^2.2.1
|
||||
"@actions/http-client": ^2.2.3
|
||||
"@actions/io": ^1.1.3
|
||||
"@actions/tool-cache": ^2.0.1
|
||||
"@azure/storage-blob": ^12.15.0
|
||||
@ -1080,7 +1090,7 @@ __metadata:
|
||||
semver: ^7.6.3
|
||||
tar-stream: ^3.1.7
|
||||
tmp: ^0.2.3
|
||||
checksum: 27fa4a500e94beff376bc322cc1074c82b20f6ceb0104c43ed5efc613763c8b7ea37b231c32c4dfcb5f7ce8a14948eecc799aa363d60d11d848466d5718d63f0
|
||||
checksum: 9dafe3c3e02f6f78c8da4cfb8bc726ae5eef9b6a2fedfca5d75ee6d6c559745c12aa16587dd595360f76be91803235dc66e0852e595ef7a582506fa0d4402983
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -3150,7 +3160,7 @@ __metadata:
|
||||
resolution: "docker-build-push@workspace:."
|
||||
dependencies:
|
||||
"@actions/core": ^1.10.1
|
||||
"@docker/actions-toolkit": 0.35.0
|
||||
"@docker/actions-toolkit": 0.39.0
|
||||
"@types/node": ^20.12.12
|
||||
"@typescript-eslint/eslint-plugin": ^7.9.0
|
||||
"@typescript-eslint/parser": ^7.9.0
|
||||
@ -5502,9 +5512,9 @@ __metadata:
|
||||
linkType: hard
|
||||
|
||||
"path-to-regexp@npm:^6.2.0":
|
||||
version: 6.2.2
|
||||
resolution: "path-to-regexp@npm:6.2.2"
|
||||
checksum: b7b0005c36f5099f9ed1fb20a820d2e4ed1297ffe683ea1d678f5e976eb9544f01debb281369dabdc26da82e6453901bf71acf2c7ed14b9243536c2a45286c33
|
||||
version: 6.3.0
|
||||
resolution: "path-to-regexp@npm:6.3.0"
|
||||
checksum: eca78602e6434a1b6799d511d375ec044e8d7e28f5a48aa5c28d57d8152fb52f3fc62fb1cfc5dfa2198e1f041c2a82ed14043d75740a2fe60e91b5089a153250
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
Reference in New Issue
Block a user