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 }}
|
||||
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 }}
|
||||
|
||||
Reference in New Issue
Block a user