Skip to content

feat: add support for Docker Build Cloud summary #1370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ actionsToolkit.run(
let dockerConfig: ConfigFile | undefined;
let dockerConfigMalformed = false;
try {
dockerConfig = await Docker.configFile();
dockerConfig = Docker.configFile();
} catch (e) {
dockerConfigMalformed = true;
core.warning(`Unable to parse config file ${path.join(Docker.configDir, 'config.json')}: ${e}`);
Expand Down Expand Up @@ -86,6 +86,9 @@ actionsToolkit.run(
await core.group(`Builder info`, async () => {
builder = await toolkit.builder.inspect(inputs.builder);
core.info(JSON.stringify(builder, null, 2));
if (builder && builder.driver) {
stateHelper.setBuilderDriver(builder.driver);
}
});

const args: string[] = await context.getArgs(inputs, toolkit);
Expand Down Expand Up @@ -173,8 +176,6 @@ actionsToolkit.run(
core.info('Build summary is not yet supported on GHES');
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
core.info('Build summary requires Buildx >= 0.13.0');
} else if (builder && builder.driver === 'cloud') {
core.info('Build summary is not yet supported with Docker Build Cloud');
} else if (!ref) {
core.info('Build summary requires a build reference');
} else {
Expand All @@ -189,7 +190,7 @@ actionsToolkit.run(
},
// post
async () => {
if (stateHelper.isSummarySupported) {
if (stateHelper.isSummarySupported && stateHelper.builderDriver !== 'cloud') {
await core.group(`Generating build summary`, async () => {
try {
const recordUploadEnabled = buildRecordUploadEnabled();
Expand Down Expand Up @@ -222,7 +223,16 @@ actionsToolkit.run(
core.warning(e.message);
}
});
} else if (stateHelper.isSummarySupported && stateHelper.builderDriver === 'cloud') {
const [, platform, refId] = stateHelper.buildRef.split('/');
await GitHub.writeCloudSummary([
{
platform: platform,
refId: refId
}
]);
}

if (stateHelper.tmpDir.length > 0) {
await core.group(`Removing temp folder ${stateHelper.tmpDir}`, async () => {
try {
Expand Down
5 changes: 5 additions & 0 deletions src/state-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {Inputs} from './context';
export const tmpDir = process.env['STATE_tmpDir'] || '';
export const buildRef = process.env['STATE_buildRef'] || '';
export const isSummarySupported = !!process.env['STATE_isSummarySupported'];
export const builderDriver = process.env['STATE_builderDriver'] || '';
export const summaryInputs = process.env['STATE_summaryInputs'] ? JSON.parse(process.env['STATE_summaryInputs']) : undefined;

export function setTmpDir(tmpDir: string) {
Expand All @@ -21,6 +22,10 @@ export function setSummarySupported() {
core.saveState('isSummarySupported', 'true');
}

export function setBuilderDriver(driver: string) {
core.saveState('builderDriver', driver);
}

export function setSummaryInputs(inputs: Inputs) {
const res = {};
for (const key of Object.keys(inputs)) {
Expand Down
Loading