From 827901539adc765796bbe1a0f21e4ddffef8ee89 Mon Sep 17 00:00:00 2001 From: UniDesk Codex Date: Sat, 4 Jul 2026 16:23:42 +0800 Subject: [PATCH] fix: skip no-op artifact collect and promote without deps --- scripts/gitops-render.mjs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/gitops-render.mjs b/scripts/gitops-render.mjs index 17dca989..af2c4cce 100644 --- a/scripts/gitops-render.mjs +++ b/scripts/gitops-render.mjs @@ -2235,6 +2235,18 @@ export HWLAB_ARTIFACT_LANE="$(params.lane)" export HWLAB_ARTIFACT_CATALOG_PATH="$(params.catalog-path)" export HWLAB_DEPLOY_MANIFEST_PATH="deploy/deploy.yaml" export HWLAB_ARTIFACT_IMAGE_TAG_MODE="$(params.image-tag-mode)" +if [ -s /workspace/source/affected-services.json ] && node - /workspace/source/affected-services.json <<'NODE' +const fs = require("node:fs"); +const plan = JSON.parse(fs.readFileSync(process.argv[2], "utf8")); +const buildServices = Array.isArray(plan.buildServices) ? plan.buildServices : []; +const affectedServices = Array.isArray(plan.affectedServices) ? plan.affectedServices : []; +process.exit(buildServices.length === 0 && affectedServices.length === 0 ? 0 : 1); +NODE +then + rm -f /workspace/source/dev-artifacts.json + echo '{"event":"collect-artifacts","status":"skipped","reason":"no-build-no-rollout-plan"}' + exit 0 +fi HWLAB_CI_PLAN_VERIFY_REUSE_REGISTRY=1 node scripts/artifact-publish.mjs --publish --lane "$(params.lane)" --catalog-path "$(params.catalog-path)" --deploy-config deploy/deploy.yaml --image-tag-mode "$(params.image-tag-mode)" --registry-prefix "$(params.registry-prefix)" --report /workspace/source/dev-artifacts.json --quiet-build --concurrency 1 --services "$(params.services)" --external-service-report-dir /workspace/source/service-results --ci-plan-path /workspace/source/affected-services.json node scripts/refresh-artifact-catalog.mjs --lane "$(params.lane)" --catalog-path "$(params.catalog-path)" --deploy-config deploy/deploy.yaml --image-tag-mode "$(params.image-tag-mode)" --target-ref HEAD --publish-report /workspace/source/dev-artifacts.json --no-write `; @@ -2303,6 +2315,18 @@ check_source_head() { } check_source_head before-render +if [ -s /workspace/source/affected-services.json ] && node - /workspace/source/affected-services.json <<'NODE' +const fs = require("node:fs"); +const plan = JSON.parse(fs.readFileSync(process.argv[2], "utf8")); +const buildServices = Array.isArray(plan.buildServices) ? plan.buildServices : []; +const affectedServices = Array.isArray(plan.affectedServices) ? plan.affectedServices : []; +process.exit(buildServices.length === 0 && affectedServices.length === 0 ? 0 : 1); +NODE +then + printf 'false' > /tekton/results/runtime-ready-required || true + echo '{"event":"gitops-promote","status":"skipped","reason":"no-build-no-rollout-plan"}' + exit 0 +fi git config --global user.name "HWLAB node GitOps Bot" git config --global user.email "hwlab-node-gitops-bot@users.noreply.github.com" catalog_path="$(params.catalog-path)"