新增 release artifact URL workflow action plan API

This commit is contained in:
2026-06-16 15:01:39 +08:00
parent b7ec759645
commit e11c29533f
9 changed files with 230 additions and 4 deletions

View File

@@ -727,6 +727,88 @@ export function createProjectReleaseReadinessArtifactUrlWorkflowSummaryViewModel
};
}
export function createProjectReleaseReadinessArtifactUrlWorkflowActionPlan(
workflow = {},
) {
const missing = arrayOrEmpty(workflow?.missing);
const ready = workflow?.ready === true;
const validationCommands = arrayOrEmpty(workflow?.actionPlan?.commands);
const inputActions = [
...(missing.includes("artifact-url")
? [{
id: "provide-artifact-url",
label: "Provide release readiness artifact URL",
kind: "input",
command: null,
expectedOutput: null,
}]
: []),
...(missing.includes("fetch")
? [{
id: "provide-fetch",
label: "Provide fetch implementation",
kind: "input",
command: null,
expectedOutput: null,
}]
: []),
...(missing.includes("artifact-fetch")
? [{
id: "verify-artifact-url-fetch",
label: "Verify release readiness artifact URL fetch",
kind: "fetch",
command: null,
expectedOutput: null,
}]
: []),
];
const commandActions = validationCommands.map((command) => ({
id: command.id ?? command.gateId ?? `command-${command.step}`,
label: command.label,
kind: "command",
command: command.command,
expectedOutput: command.expectedOutput ?? null,
}));
const actions = ready ? [] : [...inputActions, ...commandActions].map((action, index) => ({
step: index + 1,
...action,
}));
const commands = actions.filter(({ command }) => typeof command === "string" && command.length > 0);
const shellScript = commands.length > 0
? [
"#!/usr/bin/env bash",
"set -euo pipefail",
"",
...commands.map(({ command }) => command),
"",
].join("\n")
: (ready
? "# Project release readiness artifact URL workflow is already ready.\n"
: "# Project release readiness artifact URL workflow requires non-shell input.\n");
return {
apiName: "project-release-readiness-artifact-url-workflow-action-plan",
planVersion: 1,
phase: ready ? "ready" : "blocked",
ready,
missing,
actionCount: actions.length,
commandCount: commands.length,
nextActionId: actions[0]?.id ?? null,
nextCommand: commands[0]?.command ?? null,
actions,
commands,
shellScript,
rows: actions.map(({ id, label, kind, command, expectedOutput }) => ({
id,
label,
kind,
value: command ?? kind,
expectedOutput,
})),
};
}
export function createProjectReleaseReadinessArtifactValidation(artifact = {}) {
const artifactObject = objectOrEmpty(artifact);
const releaseGate = objectOrEmpty(artifactObject.releaseGate);