From 675d3d3b1a7ff032c37b8f175c0480c20f1795e3 Mon Sep 17 00:00:00 2001 From: test Date: Sun, 19 Jul 2026 20:23:39 +0800 Subject: [PATCH] ci: switch to commit-back GitOps (update values.yaml) --- .gitea/workflows/build.yml | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 9170b73..e6c3d3d 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -69,23 +69,21 @@ jobs: GITHUB_SHA: ${{ github.sha }} REGISTRY: ${{ env.REGISTRY }} - - name: Install jq - run: apk add --no-cache jq 2>/dev/null || true - - - name: Patch ArgoCD + - name: Update image tag in values.yaml (commit-back GitOps) run: | + WORK=/root/.cache/demo-frontend + cd $WORK SHORT=${GITHUB_SHA::8} - 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}" + # Use sed to update image.tag in helm values.yaml + sed -i "s/^ tag:.*/ tag: \"${SHORT}\"/" deploy/helm/values.yaml + # Show the diff + git diff deploy/helm/values.yaml + # Commit and push + git config user.email "ci@local" + git config user.name "gitea-ci" + git add deploy/helm/values.yaml + git commit -m "ci: update image tag to ${SHORT}" + git push origin main env: GITHUB_SHA: ${{ github.sha }} - REGISTRY: ${{ env.REGISTRY }} + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}