fix: 非运行态提交跳过 Todo 发布

This commit is contained in:
Codex
2026-07-10 06:59:59 +02:00
parent f128d73663
commit 5968a93a4b
7 changed files with 200 additions and 21 deletions
@@ -727,6 +727,10 @@ if (image) {
digests: loggedDigests,
gitopsCommit,
sourceCommit: image.sourceCommit || null,
runtimeSourceCommit: image.runtimeSourceCommit || null,
baselineSourceCommit: image.baselineSourceCommit || null,
action: image.action || null,
reason: image.reason || null,
valuesPrinted: false,
};
} else if (humanEnv || gitopsCommit || loggedDigests.length > 0) {
@@ -930,13 +934,15 @@ cicd_diagnostics() {
printf '%s' "${2:-{}}" >"$artifact_file"
printf '%s' "${3:-{}}" >"$argo_file"
printf '%s' "${4:-{}}" >"$runtime_file"
probe_env=$(node - "$params_file" "$pipelines_file" <<'NODE'
probe_env=$(node - "$params_file" "$pipelines_file" "$artifact_file" <<'NODE'
const fs = require('node:fs');
const params = JSON.parse(fs.readFileSync(process.argv[2], 'utf8') || '{}');
const pipelines = JSON.parse(fs.readFileSync(process.argv[3], 'utf8') || '[]');
const artifact = JSON.parse(fs.readFileSync(process.argv[4], 'utf8') || '{}');
const latest = Array.isArray(pipelines) ? pipelines[0] || {} : {};
const sourceCommit = latest.sourceCommit || null;
const tag = sourceCommit ? String(sourceCommit).slice(0, 12) : '';
const runtimeSourceCommit = artifact.runtimeSourceCommit || sourceCommit;
const tag = runtimeSourceCommit ? String(runtimeSourceCommit).slice(0, 12) : '';
const prefix = process.env.UNIDESK_PAC_CONSUMER_ID === 'unidesk-host' ? 'unidesk_host_' : '';
const param = (name) => params[`${prefix}${name}`] ?? params[name];
const imageRepository = typeof param('image_repository') === 'string' ? param('image_repository') : '';
@@ -955,6 +961,7 @@ function line(key, value) {
line('imageRepository', imageRepository);
line('registryProbeBase', probeBase);
line('sourceCommit', sourceCommit || '');
line('runtimeSourceCommit', runtimeSourceCommit || '');
line('tag', tag);
line('registryUrl', registryUrl);
line('sentinelId', param('sentinel_id') || '');
@@ -970,6 +977,7 @@ NODE
image_repository=$(printf '%s\n' "$probe_env" | sed -n 's/^imageRepository=//p' | base64 -d 2>/dev/null || true)
registry_probe_base=$(printf '%s\n' "$probe_env" | sed -n 's/^registryProbeBase=//p' | base64 -d 2>/dev/null || true)
source_commit=$(printf '%s\n' "$probe_env" | sed -n 's/^sourceCommit=//p' | base64 -d 2>/dev/null || true)
runtime_source_commit=$(printf '%s\n' "$probe_env" | sed -n 's/^runtimeSourceCommit=//p' | base64 -d 2>/dev/null || true)
image_tag=$(printf '%s\n' "$probe_env" | sed -n 's/^tag=//p' | base64 -d 2>/dev/null || true)
registry_url=$(printf '%s\n' "$probe_env" | sed -n 's/^registryUrl=//p' | base64 -d 2>/dev/null || true)
sentinel_id=$(printf '%s\n' "$probe_env" | sed -n 's/^sentinelId=//p' | base64 -d 2>/dev/null || true)
@@ -1017,6 +1025,7 @@ NODE
export UNIDESK_PAC_DIAG_IMAGE_REPOSITORY="$image_repository"
export UNIDESK_PAC_DIAG_REGISTRY_PROBE_BASE="$registry_probe_base"
export UNIDESK_PAC_DIAG_SOURCE_COMMIT="$source_commit"
export UNIDESK_PAC_DIAG_RUNTIME_SOURCE_COMMIT="$runtime_source_commit"
export UNIDESK_PAC_DIAG_IMAGE_TAG="$image_tag"
export UNIDESK_PAC_DIAG_REGISTRY_URL="$registry_url"
export UNIDESK_PAC_DIAG_REGISTRY_PRESENT="$registry_present_json"
@@ -1062,6 +1071,7 @@ const gitopsRelation = revisionRelation.relation || 'unknown';
const gitopsReady = Boolean(artifact.gitopsCommit && argo.revision);
const gitopsRevisionAligned = gitopsRelation === 'exact' || gitopsRelation === 'descendant';
const deliveryDisabled = artifact.imageStatus === 'disabled';
const deliverySkipped = artifact.imageStatus === 'skipped';
let code = 'pac-diagnostics-not-applicable';
let phase = 'not-applicable';
let ok = true;
@@ -1089,9 +1099,11 @@ if (deliveryDisabled) {
} else if (!healthReady) {
ok = false; code = 'pac-health-not-ready'; phase = 'runtime-ready-health-pending'; hint = 'runtime image is aligned but the configured health endpoint is not ready';
} else if (artifactDigest || selectedArtifactDigests.length > 0 || process.env.UNIDESK_PAC_DIAG_IMAGE_REPOSITORY) {
code = gitopsRelation === 'descendant' ? 'pac-ready-gitops-descendant' : 'pac-ready-gitops-exact';
code = deliverySkipped ? 'pac-ready-runtime-unchanged' : gitopsRelation === 'descendant' ? 'pac-ready-gitops-descendant' : 'pac-ready-gitops-exact';
phase = 'ready';
hint = gitopsRelation === 'descendant'
hint = deliverySkipped
? 'YAML-declared runtime inputs are unchanged; the existing image, GitOps manifest, runtime and health remain aligned'
: gitopsRelation === 'descendant'
? 'Argo is on a commit-graph-proven GitOps descendant and the selected artifact, runtime, Argo and health are aligned'
: 'Argo is on the exact selected GitOps commit and the artifact, runtime and health are aligned';
}
@@ -1101,6 +1113,7 @@ process.stdout.write(JSON.stringify({
phase,
hint,
sourceCommit,
runtimeSourceCommit: process.env.UNIDESK_PAC_DIAG_RUNTIME_SOURCE_COMMIT || artifact.runtimeSourceCommit || null,
imageRepository: process.env.UNIDESK_PAC_DIAG_IMAGE_REPOSITORY || null,
registryProbeBase: process.env.UNIDESK_PAC_DIAG_REGISTRY_PROBE_BASE || null,
imageTag: process.env.UNIDESK_PAC_DIAG_IMAGE_TAG || null,
@@ -1128,6 +1141,7 @@ process.stdout.write(JSON.stringify({
health: { url: healthUrl, status: healthStatus, ready: healthReady },
pipelineRun: latest.name || null,
deliveryDisabled,
deliverySkipped,
valuesPrinted: false,
}));
NODE