ci: simplify with kubectl patch (no git push)
Some checks failed
Build & Deploy Go API / build (push) Has been cancelled
Some checks failed
Build & Deploy Go API / build (push) Has been cancelled
This commit is contained in:
@@ -12,7 +12,7 @@ jobs:
|
|||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- name: Install build tools
|
- name: Install build tools
|
||||||
run: apk add --no-cache curl git docker-cli 2>/dev/null || true
|
run: apk add --no-cache curl git docker-cli jq 2>/dev/null || true
|
||||||
|
|
||||||
- name: Clone + prepare
|
- name: Clone + prepare
|
||||||
run: |
|
run: |
|
||||||
@@ -42,18 +42,14 @@ jobs:
|
|||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
REGISTRY: ${{ env.REGISTRY }}
|
REGISTRY: ${{ env.REGISTRY }}
|
||||||
|
|
||||||
- name: Update image tag in values.yaml (commit-back GitOps)
|
- name: Update ArgoCD
|
||||||
run: |
|
run: |
|
||||||
cd /root/.cache/demo-go-api
|
|
||||||
SHORT=${GITHUB_SHA::8}
|
SHORT=${GITHUB_SHA::8}
|
||||||
sed -i "s/^ tag:.*/ tag: \"${SHORT}\"/" deploy/helm/values.yaml
|
# Use kubectl to update ArgoCD image tag directly (no git push needed)
|
||||||
git config user.email "ci@local"
|
PATCH=$(jq -n --arg tag "$SHORT" --arg reg "$REGISTRY" \
|
||||||
git config user.name "gitea-ci"
|
'{"spec":{"source":{"helm":{"parameters":[{"name":"image.registry","value":$reg},{"name":"image.tag","value":$tag}]}}}}')
|
||||||
git add deploy/helm/values.yaml
|
kubectl -n cicd patch application demo-go-api --type=merge -p "$PATCH"
|
||||||
git commit -m "ci: update image tag to ${SHORT}" || echo "nothing to commit"
|
echo "✓ ArgoCD updated with tag ${SHORT}"
|
||||||
# Try push but don't fail if Gitea is unreachable
|
|
||||||
git push origin main || echo "⚠ push failed - Gitea may be unreachable from cluster"
|
|
||||||
echo "✓ Done with tag ${SHORT}"
|
|
||||||
env:
|
env:
|
||||||
GITHUB_SHA: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
REGISTRY: ${{ env.REGISTRY }}
|
||||||
|
|||||||
Reference in New Issue
Block a user