ci: use jq for reliable ArgoCD patch
Some checks failed
Build & Deploy / build (push) Failing after 1m49s
Some checks failed
Build & Deploy / build (push) Failing after 1m49s
This commit is contained in:
@@ -69,14 +69,23 @@ jobs:
|
|||||||
GITHUB_SHA: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
REGISTRY: ${{ env.REGISTRY }}
|
REGISTRY: ${{ env.REGISTRY }}
|
||||||
|
|
||||||
|
- name: Install jq
|
||||||
|
run: apk add --no-cache jq 2>/dev/null || true
|
||||||
|
|
||||||
- name: Patch ArgoCD
|
- name: Patch ArgoCD
|
||||||
run: |
|
run: |
|
||||||
SHORT=${GITHUB_SHA::8}
|
SHORT=${GITHUB_SHA::8}
|
||||||
|
for i in {1..10}; do
|
||||||
if kubectl -n cicd get application demo-frontend &>/dev/null; then
|
if kubectl -n cicd get application demo-frontend &>/dev/null; then
|
||||||
kubectl -n cicd patch application demo-frontend --type merge \
|
break
|
||||||
-p "{\"spec\":{\"source\":{\"helm\":{\"parameters\":[{\"name\":\"image.registry\",\"value\":\"${REGISTRY}\"},{\"name\":\"image.tag\",\"value\":\"${SHORT}\"}]}}}}"
|
|
||||||
echo "✓ ArgoCD app patched"
|
|
||||||
fi
|
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:
|
env:
|
||||||
GITHUB_SHA: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
REGISTRY: ${{ env.REGISTRY }}
|
REGISTRY: ${{ env.REGISTRY }}
|
||||||
|
|||||||
Reference in New Issue
Block a user