mirror of
https://github.com/docker/bake-action.git
synced 2026-01-23 12:44:17 +01:00
generate GitHub annotations for build checks
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
@@ -641,3 +641,30 @@ jobs:
|
|||||||
targets: app
|
targets: app
|
||||||
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:
|
||||||
|
workdir: ./test
|
||||||
|
files: |
|
||||||
|
./lint.hcl
|
||||||
|
|||||||
16
src/main.ts
16
src/main.ts
@@ -119,7 +119,8 @@ actionsToolkit.run(
|
|||||||
const args: string[] = await context.getArgs(inputs, definition, toolkit);
|
const args: string[] = await context.getArgs(inputs, definition, toolkit);
|
||||||
const buildCmd = await toolkit.buildx.getCommand(args);
|
const buildCmd = await toolkit.buildx.getCommand(args);
|
||||||
const buildEnv = Object.assign({}, process.env, {
|
const buildEnv = Object.assign({}, process.env, {
|
||||||
BUILDX_BAKE_GIT_AUTH_TOKEN: gitAuthToken
|
BUILDX_BAKE_GIT_AUTH_TOKEN: gitAuthToken,
|
||||||
|
BUILDX_METADATA_WARNINGS: 'true'
|
||||||
}) as {
|
}) as {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
@@ -164,6 +165,19 @@ actionsToolkit.run(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const warnings = toolkit.buildxBake.resolveWarnings(metadata);
|
||||||
|
if (refs.length > 0 && warnings && warnings.length > 0) {
|
||||||
|
const annotations = await Buildx.convertWarningsToGitHubAnnotations(warnings, refs);
|
||||||
|
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');
|
||||||
|
|||||||
10
test/lint-other.Dockerfile
Normal file
10
test/lint-other.Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
frOM busybox as base
|
||||||
|
cOpy lint-other.Dockerfile .
|
||||||
|
|
||||||
|
froM busybox aS notused
|
||||||
|
COPY lint-other.Dockerfile .
|
||||||
|
|
||||||
|
from scratch
|
||||||
|
COPy --from=base \
|
||||||
|
/lint-other.Dockerfile \
|
||||||
|
/
|
||||||
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
|
||||||
12
test/lint.hcl
Normal file
12
test/lint.hcl
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
group "default" {
|
||||||
|
targets = ["lint", "lint-other", "lint-inline"]
|
||||||
|
}
|
||||||
|
target "lint" {
|
||||||
|
dockerfile = "lint.Dockerfile"
|
||||||
|
}
|
||||||
|
target "lint-other" {
|
||||||
|
dockerfile = "lint-other.Dockerfile"
|
||||||
|
}
|
||||||
|
target "lint-inline" {
|
||||||
|
dockerfile-inline = "FRoM alpine\nENTRYPOINT [\"echo\", \"hello\"]"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user