diff --git a/scripts/artifact-publish.mjs b/scripts/artifact-publish.mjs index 02d67754..ebbb9f8b 100644 --- a/scripts/artifact-publish.mjs +++ b/scripts/artifact-publish.mjs @@ -738,12 +738,19 @@ function bootShForService(deployManifest, serviceId, lane) { return text; } -function normalizeCatalogForLane(catalog, lane, deployManifest) { +function normalizeCatalogForLane(catalog, args, deployManifest, commitId) { + const lane = args?.lane; if (!catalog || !isRuntimeArtifactLane(lane)) return catalog; - const allowed = new Set(runtimeLaneServiceIdsFromDeploy(deployManifest, lane)); + const serviceIds = runtimeLaneServiceIdsFromDeploy(deployManifest, lane); + const allowed = new Set(serviceIds); + const existingById = new Map((catalog.services ?? []) + .filter((service) => allowed.has(service.serviceId)) + .map((service) => [service.serviceId, service])); + const tag = imageTagForCommit(args, commitId); return { ...catalog, - services: (catalog.services ?? []).filter((service) => allowed.has(service.serviceId)) + services: serviceIds.map((serviceId) => existingById.get(serviceId) + ?? artifactCatalogSkeletonService({ args, deployManifest, serviceId, tag, commitId })) }; } @@ -2297,7 +2304,7 @@ async function main() { let catalog = await readConfigIfPresent(args.catalogPath, null); const catalogWasMissing = !catalog; if (!catalog && isRuntimeArtifactLane(args.lane)) catalog = artifactCatalogSkeleton({ args, deployManifest, commitId }); - catalog = normalizeCatalogForLane(catalog, args.lane, deployManifest); + catalog = normalizeCatalogForLane(catalog, args, deployManifest, commitId); assert.ok(catalog, `${args.catalogPath} is required for ${args.lane} artifact publish`); const shortCommit = imageTagForCommit(args, commitId); let effectiveCatalogPath = args.catalogPath;