diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 7a0418d..d0c413f 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: self-hosted steps: - name: Install build tools - run: apk add --no-cache curl git docker-cli jq 2>/dev/null || true + run: apk add --no-cache curl git docker-cli 2>/dev/null || true - name: Clone + prepare run: | @@ -42,22 +42,21 @@ jobs: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} REGISTRY: ${{ env.REGISTRY }} - - name: Update ArgoCD + - name: Update image tag in values.yaml (commit-back GitOps) run: | + WORK=/root/.cache/demo-go-api + cd $WORK SHORT=${GITHUB_SHA::8} - # Wait for ArgoCD to be ready - for i in {1..10}; do - if kubectl -n cicd get application demo-go-api &>/dev/null; then - break - fi - echo "Waiting for ArgoCD application..." - sleep 3 - done - # Patch using JSON - 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-go-api --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 }}