ci: use jq for reliable ArgoCD patch
Some checks failed
Build & Deploy / build (push) Failing after 1m49s

This commit is contained in:
test
2026-07-19 20:12:19 +08:00
parent df676c0d18
commit 21bad3ec62

View File

@@ -69,14 +69,23 @@ jobs:
GITHUB_SHA: ${{ github.sha }}
REGISTRY: ${{ env.REGISTRY }}
- name: Install jq
run: apk add --no-cache jq 2>/dev/null || true
- name: Patch ArgoCD
run: |
SHORT=${GITHUB_SHA::8}
if kubectl -n cicd get application demo-frontend &>/dev/null; then
kubectl -n cicd patch application demo-frontend --type merge \
-p "{\"spec\":{\"source\":{\"helm\":{\"parameters\":[{\"name\":\"image.registry\",\"value\":\"${REGISTRY}\"},{\"name\":\"image.tag\",\"value\":\"${SHORT}\"}]}}}}"
echo "✓ ArgoCD app patched"
fi
for i in {1..10}; do
if kubectl -n cicd get application demo-frontend &>/dev/null; then
break
fi
echo "Waiting for ArgoCD application..."
sleep 3
done
PATCH=$(jq -n --arg tag "$SHORT" --arg reg "$REGISTRY" \
'{"spec":{"source":{"helm":{"parameters":[{"name":"image.registry","value":$reg},{"name":"image.tag","value":$tag}]}}}}')
kubectl -n cicd patch application demo-frontend --type=merge -p "$PATCH"
echo "✓ ArgoCD updated with tag ${SHORT}"
env:
GITHUB_SHA: ${{ github.sha }}
REGISTRY: ${{ env.REGISTRY }}