Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/buildx/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class History {
numCachedSteps: res.NumCachedSteps,
numTotalSteps: res.NumTotalSteps,
numCompletedSteps: res.NumCompletedSteps,
defaultPlatform: res.Platform?.[0],
error: errorLogs
};
});
Expand Down Expand Up @@ -283,10 +284,10 @@ export class History {
return {
dockerbuildFilename: dockerbuildPath,
dockerbuildSize: dockerbuildStats.size,
summaries: summaries,
builderName: builderName,
nodeName: nodeName,
refs: refs
refs: refs,
summaries: summaries
};
}

Expand Down
61 changes: 47 additions & 14 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,23 @@ export class GitHub {
};

const refsSize = Object.keys(opts.exportRes.refs).length;
const singleRef = refsSize === 1 ? Object.keys(opts.exportRes.refs)[0] : undefined;
const singleSummary = singleRef && opts.exportRes.summaries?.[singleRef];
const dbcAccount = opts.driver === 'cloud' && opts.endpoint?.split('/')[0];

const sum = core.summary.addHeading('Docker Build summary', 2);

if (dbcAccount && singleRef && singleSummary) {
const buildURL = GitHub.formatDBCBuildURL(dbcAccount, singleRef, singleSummary.defaultPlatform);
// prettier-ignore
sum.addRaw(`<p>`)
.addRaw(`For a detailed look at the build, you can check the results at:`)
.addRaw('</p>')
.addRaw(`<p>`)
.addRaw(`:whale: ${addLink(`<strong>${buildURL}</strong>`, buildURL)}`)
.addRaw(`</p>`);
}

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
Expand All @@ -246,17 +260,29 @@ export class GitHub {
// https://github.com/docker/actions-toolkit/issues/367
const artifactRelativeURL = `./${GitHub.runId}/${opts.uploadRes.url.split('/').slice(-2).join('/')}`;

if (dbcAccount && refsSize === 1) {
// prettier-ignore
sum.addRaw(`<p>`)
.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('</p>')
} else {
// prettier-ignore
sum.addRaw(`<p>`)
.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('</p>')
}

// prettier-ignore
sum.addRaw(`<p>`)
.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('</p>')
.addRaw(`<p>`)
.addRaw(`:arrow_down: ${addLink(`<strong>${Util.stringToUnicodeEntities(opts.uploadRes.filename)}</strong>`, artifactRelativeURL)} (${Util.formatFileSize(opts.uploadRes.size)} - includes <strong>${refsSize} build record${refsSize > 1 ? 's' : ''}</strong>)`)
.addRaw(`</p>`);
} else {
} else if (opts.exportRes.summaries) {
// prettier-ignore
sum.addRaw(`<p>`)
.addRaw(`The following table provides a brief summary of your build.`)
Expand All @@ -273,12 +299,14 @@ export class GitHub {
// Preview
sum.addRaw('<p>');
const summaryTableData: Array<Array<SummaryTableCell>> = [
// prettier-ignore
[
{header: true, data: 'ID'},
{header: true, data: 'Name'},
{header: true, data: 'Status'},
{header: true, data: 'Cached'},
{header: true, data: 'Duration'}
{header: true, data: 'Duration'},
...(dbcAccount && refsSize > 1 ? [{header: true, data: 'Build result URL'}] : [])
]
];
let buildError: string | undefined;
Expand All @@ -287,12 +315,13 @@ export class GitHub {
const summary = opts.exportRes.summaries[ref];
// prettier-ignore
summaryTableData.push([
{data: `<code>${ref.substring(0, 6).toUpperCase()}</code>`},
{data: `<strong>${Util.stringToUnicodeEntities(summary.name)}</strong>`},
{data: `${summary.status === 'completed' ? ':white_check_mark:' : summary.status === 'canceled' ? ':no_entry_sign:' : ':x:'} ${summary.status}`},
{data: `${summary.numCachedSteps > 0 ? Math.round((summary.numCachedSteps / summary.numTotalSteps) * 100) : 0}%`},
{data: summary.duration}
]);
{data: `<code>${ref.substring(0, 6).toUpperCase()}</code>`},
{data: `<strong>${Util.stringToUnicodeEntities(summary.name)}</strong>`},
{data: `${summary.status === 'completed' ? ':white_check_mark:' : summary.status === 'canceled' ? ':no_entry_sign:' : ':x:'} ${summary.status}`},
{data: `${summary.numCachedSteps > 0 ? Math.round((summary.numCachedSteps / summary.numTotalSteps) * 100) : 0}%`},
{data: summary.duration},
...(dbcAccount && refsSize > 1 ? [{data: addLink(':whale: Open', GitHub.formatDBCBuildURL(dbcAccount, ref, summary.defaultPlatform))}] : [])
]);
if (summary.error) {
buildError = summary.error;
}
Expand Down Expand Up @@ -347,4 +376,8 @@ export class GitHub {
core.info(`Writing summary`);
await sum.addSeparator().write();
}

private static formatDBCBuildURL(account: string, ref: string, platform?: string): string {
return `https://app.docker.com/build/accounts/${account}/builds/${(platform ?? 'linux/amd64').replace('/', '-')}/${ref}`;
}
}
1 change: 1 addition & 0 deletions src/types/buildx/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@ export interface Summary {
numTotalSteps: number;
numCompletedSteps: number;
frontendAttrs?: Record<string, string>;
defaultPlatform?: string;
error?: string;
}
3 changes: 3 additions & 0 deletions src/types/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ export interface BuildSummaryOpts {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
inputs?: any;
bakeDefinition?: BakeDefinition;
// builder options
driver?: string;
endpoint?: string;
}
Loading