ci: switch to commit-back GitOps (update values.yaml)
Some checks failed
Build & Deploy / build (push) Failing after 7s
Some checks failed
Build & Deploy / build (push) Failing after 7s
This commit is contained in:
@@ -69,23 +69,21 @@ jobs:
|
|||||||
GITHUB_SHA: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
REGISTRY: ${{ env.REGISTRY }}
|
REGISTRY: ${{ env.REGISTRY }}
|
||||||
|
|
||||||
- name: Install jq
|
- name: Update image tag in values.yaml (commit-back GitOps)
|
||||||
run: apk add --no-cache jq 2>/dev/null || true
|
|
||||||
|
|
||||||
- name: Patch ArgoCD
|
|
||||||
run: |
|
run: |
|
||||||
|
WORK=/root/.cache/demo-frontend
|
||||||
|
cd $WORK
|
||||||
SHORT=${GITHUB_SHA::8}
|
SHORT=${GITHUB_SHA::8}
|
||||||
for i in {1..10}; do
|
# Use sed to update image.tag in helm values.yaml
|
||||||
if kubectl -n cicd get application demo-frontend &>/dev/null; then
|
sed -i "s/^ tag:.*/ tag: \"${SHORT}\"/" deploy/helm/values.yaml
|
||||||
break
|
# Show the diff
|
||||||
fi
|
git diff deploy/helm/values.yaml
|
||||||
echo "Waiting for ArgoCD application..."
|
# Commit and push
|
||||||
sleep 3
|
git config user.email "ci@local"
|
||||||
done
|
git config user.name "gitea-ci"
|
||||||
PATCH=$(jq -n --arg tag "$SHORT" --arg reg "$REGISTRY" \
|
git add deploy/helm/values.yaml
|
||||||
'{"spec":{"source":{"helm":{"parameters":[{"name":"image.registry","value":$reg},{"name":"image.tag","value":$tag}]}}}}')
|
git commit -m "ci: update image tag to ${SHORT}"
|
||||||
kubectl -n cicd patch application demo-frontend --type=merge -p "$PATCH"
|
git push origin main
|
||||||
echo "✓ ArgoCD updated with tag ${SHORT}"
|
|
||||||
env:
|
env:
|
||||||
GITHUB_SHA: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
REGISTRY: ${{ env.REGISTRY }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
|||||||
Reference in New Issue
Block a user