From cc1a989b3a75fbca900e1e5fea710853072395d8 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Mon, 12 May 2025 17:14:03 +0200 Subject: [PATCH] github: support build URL when writing summary Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- src/github.ts | 36 +++++++++++++++++++++++++++++------- src/types/github.ts | 1 + 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/github.ts b/src/github.ts index da2298d..e839e15 100644 --- a/src/github.ts +++ b/src/github.ts @@ -237,6 +237,16 @@ export class GitHub { const sum = core.summary.addHeading('Docker Build summary', 2); + if (opts.buildURL) { + // prettier-ignore + sum.addRaw(`
`) + .addRaw(`For a detailed look at the build, you can check the results at:`) + .addRaw('
') + .addRaw(``) + .addRaw(`:whale: ${addLink(`${opts.buildURL}`, opts.buildURL)}`) + .addRaw(`
`); + } + if (opts.uploadRes) { // we just need the last two parts of the URL as they are always relative // to the workflow run URL otherwise URL could be broken if GitHub @@ -246,17 +256,29 @@ export class GitHub { // https://github.com/docker/actions-toolkit/issues/367 const artifactRelativeURL = `./${GitHub.runId}/${opts.uploadRes.url.split('/').slice(-2).join('/')}`; + if (opts.buildURL) { + // prettier-ignore + sum.addRaw(``) + .addRaw(`You can also download the following build record archive and import it into Docker Desktop's Builds view. `) + .addBreak() + .addRaw(`Build records include details such as timing, dependencies, results, logs, traces, and other information about a build. `) + .addRaw(addLink('Learn more', 'https://www.docker.com/blog/new-beta-feature-deep-dive-into-github-actions-docker-builds-with-docker-desktop/?utm_source=github&utm_medium=actions')) + .addRaw('
') + } else { + // prettier-ignore + sum.addRaw(``) + .addRaw(`For a detailed look at the build, download the following build record archive and import it into Docker Desktop's Builds view. `) + .addBreak() + .addRaw(`Build records include details such as timing, dependencies, results, logs, traces, and other information about a build. `) + .addRaw(addLink('Learn more', 'https://www.docker.com/blog/new-beta-feature-deep-dive-into-github-actions-docker-builds-with-docker-desktop/?utm_source=github&utm_medium=actions')) + .addRaw('
') + } + // prettier-ignore sum.addRaw(``) - .addRaw(`For a detailed look at the build, download the following build record archive and import it into Docker Desktop's Builds view. `) - .addBreak() - .addRaw(`Build records include details such as timing, dependencies, results, logs, traces, and other information about a build. `) - .addRaw(addLink('Learn more', 'https://www.docker.com/blog/new-beta-feature-deep-dive-into-github-actions-docker-builds-with-docker-desktop/?utm_source=github&utm_medium=actions')) - .addRaw('
') - .addRaw(``) .addRaw(`:arrow_down: ${addLink(`${Util.stringToUnicodeEntities(opts.uploadRes.filename)}`, artifactRelativeURL)} (${Util.formatFileSize(opts.uploadRes.size)} - includes ${refsSize} build record${refsSize > 1 ? 's' : ''})`) .addRaw(`
`); - } else { + } else if (opts.exportRes.summaries) { // prettier-ignore sum.addRaw(``) .addRaw(`The following table provides a brief summary of your build.`) diff --git a/src/types/github.ts b/src/types/github.ts index 8613854..4e0eb24 100644 --- a/src/types/github.ts +++ b/src/types/github.ts @@ -59,6 +59,7 @@ export interface UploadArtifactResponse { export interface BuildSummaryOpts { exportRes: ExportResponse; uploadRes?: UploadArtifactResponse; + buildURL?: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any inputs?: any; bakeDefinition?: BakeDefinition;