mirror of
https://github.com/docker/build-push-action.git
synced 2026-01-20 09:28:56 +08:00
- Add summaryType state to distinguish between buildx and cloud summaries. - Generate a Docker Build Cloud summary with a direct link to build details on app.docker.com when using the cloud driver. - Refactor state-helper to use summaryType instead of isSummarySupported. - Improve summary selection logic and output for both buildx and cloud drivers. - Add informative logging for cloud build summary links. Signed-off-by: Nicolas Beck <nicolas.beck@docker.com>
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import * as core from '@actions/core';
|
|
|
|
import {Build} from '@docker/actions-toolkit/lib/buildx/build';
|
|
|
|
import {Inputs} from './context';
|
|
|
|
export const tmpDir = process.env['STATE_tmpDir'] || '';
|
|
export const buildRef = process.env['STATE_buildRef'] || '';
|
|
export const summaryType = process.env['STATE_summaryType'] || undefined;
|
|
export const summaryInputs = process.env['STATE_summaryInputs'] ? JSON.parse(process.env['STATE_summaryInputs']) : undefined;
|
|
|
|
export function setTmpDir(tmpDir: string) {
|
|
core.saveState('tmpDir', tmpDir);
|
|
}
|
|
|
|
export function setBuildRef(buildRef: string) {
|
|
core.saveState('buildRef', buildRef);
|
|
}
|
|
|
|
export function setSummaryType(summaryType: string) {
|
|
core.saveState('summaryType', summaryType);
|
|
}
|
|
|
|
export function setSummaryInputs(inputs: Inputs) {
|
|
const res = {};
|
|
for (const key of Object.keys(inputs)) {
|
|
if (key === 'github-token') {
|
|
continue;
|
|
}
|
|
const value: string | string[] | boolean = inputs[key];
|
|
if (typeof value === 'boolean' && !value) {
|
|
continue;
|
|
} else if (Array.isArray(value)) {
|
|
if (value.length === 0) {
|
|
continue;
|
|
} else if (key === 'secrets' && value.length > 0) {
|
|
const secretKeys: string[] = [];
|
|
for (const secret of value) {
|
|
try {
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
const [skey, _] = Build.parseSecretKvp(secret, true);
|
|
secretKeys.push(skey);
|
|
} catch (err) {
|
|
// ignore invalid secret
|
|
}
|
|
}
|
|
if (secretKeys.length > 0) {
|
|
res[key] = secretKeys;
|
|
}
|
|
continue;
|
|
}
|
|
} else if (!value) {
|
|
continue;
|
|
}
|
|
res[key] = value;
|
|
}
|
|
core.saveState('summaryInputs', JSON.stringify(res));
|
|
}
|