mirror of
https://github.com/docker/build-push-action.git
synced 2026-01-18 01:58:31 +00:00
Merge pull request #1197 from crazy-max/build-checks
Some checks failed
validate / prepare (push) Successful in 13s
test / test (push) Successful in 50s
validate / validate (push) Successful in 58s
e2e / build (Artifactory, ARTIFACTORY_TOKEN, infradock.jfrog.io, infradock.jfrog.io/test-ghaction/build-push-action, remote, ARTIFACTORY_USERNAME) (push) Failing after 20s
e2e / build (AWS ECR, AWS_SECRET_ACCESS_KEY, 175142243308.dkr.ecr.us-east-2.amazonaws.com, 175142243308.dkr.ecr.us-east-2.amazonaws.com/sandbox/test-docker-action, remote, AWS_ACCESS_KEY_ID) (push) Failing after 21s
e2e / build (AWS ECR Public, AWS_SECRET_ACCESS_KEY, public.ecr.aws, public.ecr.aws/q3b5f1u4/test-docker-action, remote, AWS_ACCESS_KEY_ID) (push) Failing after 33s
e2e / build (Azure Container Registry, AZURE_CLIENT_SECRET, officialgithubactions.azurecr.io, officialgithubactions.azurecr.io/test-docker-action, remote, AZURE_CLIENT_ID) (push) Failing after 18s
e2e / build (Docker Hub, DOCKERHUB_TOKEN, , ghactionstest/ghactionstest, remote, DOCKERHUB_USERNAME) (push) Failing after 19s
e2e / build (GitHub, GHCR_PAT, ghcr.io, ghcr.io/docker-ghactiontest/test, remote, GHCR_USERNAME) (push) Failing after 18s
e2e / build (Google Container Registry, GCR_JSON_KEY, gcr.io, gcr.io/sandbox-298914/test-docker-action, remote, GCR_USERNAME) (push) Failing after 19s
e2e / build (distribution, Distribution, local) (push) Failing after 16s
e2e / build (harbor, Harbor, local) (push) Failing after 16s
e2e / build (GitLab, GITLAB_TOKEN, registry.gitlab.com, registry.gitlab.com/test1716/test, remote, GITLAB_USERNAME) (push) Failing after 18s
e2e / build (Quay, QUAY_TOKEN, quay.io, quay.io/docker_build_team/ghactiontest, remote, QUAY_USERNAME) (push) Failing after 18s
e2e / build (Google Artifact Registry, GAR_JSON_KEY, us-east4-docker.pkg.dev, us-east4-docker.pkg.dev/sandbox-298914/docker-official-github-actions/test-docker-action, remote, GAR_USERNAME) (push) Failing after 19s
e2e / build (nexus, Nexus, local) (push) Failing after 15s
Some checks failed
validate / prepare (push) Successful in 13s
test / test (push) Successful in 50s
validate / validate (push) Successful in 58s
e2e / build (Artifactory, ARTIFACTORY_TOKEN, infradock.jfrog.io, infradock.jfrog.io/test-ghaction/build-push-action, remote, ARTIFACTORY_USERNAME) (push) Failing after 20s
e2e / build (AWS ECR, AWS_SECRET_ACCESS_KEY, 175142243308.dkr.ecr.us-east-2.amazonaws.com, 175142243308.dkr.ecr.us-east-2.amazonaws.com/sandbox/test-docker-action, remote, AWS_ACCESS_KEY_ID) (push) Failing after 21s
e2e / build (AWS ECR Public, AWS_SECRET_ACCESS_KEY, public.ecr.aws, public.ecr.aws/q3b5f1u4/test-docker-action, remote, AWS_ACCESS_KEY_ID) (push) Failing after 33s
e2e / build (Azure Container Registry, AZURE_CLIENT_SECRET, officialgithubactions.azurecr.io, officialgithubactions.azurecr.io/test-docker-action, remote, AZURE_CLIENT_ID) (push) Failing after 18s
e2e / build (Docker Hub, DOCKERHUB_TOKEN, , ghactionstest/ghactionstest, remote, DOCKERHUB_USERNAME) (push) Failing after 19s
e2e / build (GitHub, GHCR_PAT, ghcr.io, ghcr.io/docker-ghactiontest/test, remote, GHCR_USERNAME) (push) Failing after 18s
e2e / build (Google Container Registry, GCR_JSON_KEY, gcr.io, gcr.io/sandbox-298914/test-docker-action, remote, GCR_USERNAME) (push) Failing after 19s
e2e / build (distribution, Distribution, local) (push) Failing after 16s
e2e / build (harbor, Harbor, local) (push) Failing after 16s
e2e / build (GitLab, GITLAB_TOKEN, registry.gitlab.com, registry.gitlab.com/test1716/test, remote, GITLAB_USERNAME) (push) Failing after 18s
e2e / build (Quay, QUAY_TOKEN, quay.io, quay.io/docker_build_team/ghactiontest, remote, QUAY_USERNAME) (push) Failing after 18s
e2e / build (Google Artifact Registry, GAR_JSON_KEY, us-east4-docker.pkg.dev, us-east4-docker.pkg.dev/sandbox-298914/docker-official-github-actions/test-docker-action, remote, GAR_USERNAME) (push) Failing after 19s
e2e / build (nexus, Nexus, local) (push) Failing after 15s
generate GitHub annotations for build checks
This commit is contained in:
48
.github/workflows/ci.yml
vendored
48
.github/workflows/ci.yml
vendored
@@ -1463,3 +1463,51 @@ jobs:
|
|||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
env:
|
env:
|
||||||
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
|
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 |
|
| 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_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_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` |
|
| `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` |
|
||||||
|
|||||||
2
dist/index.js
generated
vendored
2
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
33
src/main.ts
33
src/main.ts
@@ -97,7 +97,12 @@ actionsToolkit.run(
|
|||||||
|
|
||||||
let err: Error | undefined;
|
let err: Error | undefined;
|
||||||
await Exec.getExecOutput(buildCmd.command, buildCmd.args, {
|
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 => {
|
}).then(res => {
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
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 imageID = toolkit.buildxBuild.resolveImageID();
|
||||||
const metadata = toolkit.buildxBuild.resolveMetadata();
|
const metadata = toolkit.buildxBuild.resolveMetadata();
|
||||||
const digest = toolkit.buildxBuild.resolveDigest();
|
const digest = toolkit.buildxBuild.resolveDigest(metadata);
|
||||||
if (imageID) {
|
if (imageID) {
|
||||||
await core.group(`ImageID`, async () => {
|
await core.group(`ImageID`, async () => {
|
||||||
core.info(imageID);
|
core.info(imageID);
|
||||||
@@ -127,7 +132,7 @@ actionsToolkit.run(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let ref: string;
|
let ref: string | undefined;
|
||||||
await core.group(`Reference`, async () => {
|
await core.group(`Reference`, async () => {
|
||||||
ref = await buildRef(toolkit, startedTime, inputs.builder);
|
ref = await buildRef(toolkit, startedTime, inputs.builder);
|
||||||
if (ref) {
|
if (ref) {
|
||||||
@@ -138,6 +143,21 @@ 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 () => {
|
await core.group(`Check build summary support`, async () => {
|
||||||
if (!buildSummaryEnabled()) {
|
if (!buildSummaryEnabled()) {
|
||||||
core.info('Build summary disabled');
|
core.info('Build summary disabled');
|
||||||
@@ -222,6 +242,13 @@ 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 buildChecksAnnotationsEnabled(): boolean {
|
||||||
|
if (process.env.DOCKER_BUILD_CHECKS_ANNOTATIONS) {
|
||||||
|
return Util.parseBool(process.env.DOCKER_BUILD_CHECKS_ANNOTATIONS);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function buildSummaryEnabled(): boolean {
|
function buildSummaryEnabled(): boolean {
|
||||||
if (process.env.DOCKER_BUILD_NO_SUMMARY) {
|
if (process.env.DOCKER_BUILD_NO_SUMMARY) {
|
||||||
core.warning('DOCKER_BUILD_NO_SUMMARY is deprecated. Set DOCKER_BUILD_SUMMARY to false instead.');
|
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
|
||||||
Reference in New Issue
Block a user