Skip to content

Commit 175aa53

Browse files
committed
opt to disable github annotations generation for build checks
Signed-off-by: CrazyMax <[email protected]>
1 parent 806a2a4 commit 175aa53

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,3 +1489,25 @@ jobs:
14891489
with:
14901490
context: ./test
14911491
file: ./test/lint.Dockerfile
1492+
1493+
annotations-disabled:
1494+
runs-on: ubuntu-latest
1495+
steps:
1496+
-
1497+
name: Checkout
1498+
uses: actions/checkout@v4
1499+
-
1500+
name: Set up Docker Buildx
1501+
uses: docker/setup-buildx-action@v3
1502+
with:
1503+
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
1504+
driver-opts: |
1505+
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
1506+
-
1507+
name: Build
1508+
uses: ./
1509+
with:
1510+
context: ./test
1511+
file: ./test/lint.Dockerfile
1512+
env:
1513+
DOCKER_BUILD_CHECKS_ANNOTATIONS: false

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ The following outputs are available:
258258

259259
| Name | Type | Default | Description |
260260
|--------------------------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
261+
| `DOCKER_BUILD_CHECKS_ANNOTATIONS` | Bool | `true` | If `false`, GitHub annotations are not generated for [build checks](https://docs.docker.com/build/checks/) |
261262
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled |
262263
| `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 |
263264
| `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` |

src/main.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,18 @@ actionsToolkit.run(
143143
}
144144
});
145145

146-
const warnings = toolkit.buildxBuild.resolveWarnings(metadata);
147-
if (ref && warnings && warnings.length > 0) {
148-
const annotations = await Buildx.convertWarningsToGitHubAnnotations(warnings, [ref]);
149-
core.debug(`annotations: ${JSON.stringify(annotations, null, 2)}`);
150-
if (annotations && annotations.length > 0) {
151-
await core.group(`Generating GitHub annotations (${annotations.length} build checks found)`, async () => {
152-
for (const annotation of annotations) {
153-
core.warning(annotation.message, annotation);
154-
}
155-
});
146+
if (buildChecksAnnotationsEnabled()) {
147+
const warnings = toolkit.buildxBuild.resolveWarnings(metadata);
148+
if (ref && warnings && warnings.length > 0) {
149+
const annotations = await Buildx.convertWarningsToGitHubAnnotations(warnings, [ref]);
150+
core.debug(`annotations: ${JSON.stringify(annotations, null, 2)}`);
151+
if (annotations && annotations.length > 0) {
152+
await core.group(`Generating GitHub annotations (${annotations.length} build checks found)`, async () => {
153+
for (const annotation of annotations) {
154+
core.warning(annotation.message, annotation);
155+
}
156+
});
157+
}
156158
}
157159
}
158160

@@ -240,6 +242,13 @@ async function buildRef(toolkit: Toolkit, since: Date, builder?: string): Promis
240242
return Object.keys(refs).length > 0 ? Object.keys(refs)[0] : '';
241243
}
242244

245+
function buildChecksAnnotationsEnabled(): boolean {
246+
if (process.env.DOCKER_BUILD_CHECKS_ANNOTATIONS) {
247+
return Util.parseBool(process.env.DOCKER_BUILD_CHECKS_ANNOTATIONS);
248+
}
249+
return true;
250+
}
251+
243252
function buildSummaryEnabled(): boolean {
244253
if (process.env.DOCKER_BUILD_NO_SUMMARY) {
245254
core.warning('DOCKER_BUILD_NO_SUMMARY is deprecated. Set DOCKER_BUILD_SUMMARY to false instead.');

0 commit comments

Comments
 (0)