From 2de1e60b8a25d4149df251c37aa9bcb0a69ff5a9 Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Thu, 18 Jun 2026 14:23:30 -0500 Subject: [PATCH] fix(ci): update infra manifests after blue-green swap --- .gitea/workflows/deploy-gke.yaml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.gitea/workflows/deploy-gke.yaml b/.gitea/workflows/deploy-gke.yaml index 94d17b7..0f78881 100644 --- a/.gitea/workflows/deploy-gke.yaml +++ b/.gitea/workflows/deploy-gke.yaml @@ -200,6 +200,46 @@ jobs: --image "${{ steps.vars.outputs.image }}" \ --slot "${{ steps.vars.outputs.slot }}" + - name: Update infrastructure manifests + if: success() + env: + INFRA_GIT_TOKEN: ${{ secrets.INFRA_GIT_TOKEN }} + run: | + SLOT="${{ steps.vars.outputs.slot }}" + if [ "$SLOT" = "blue" ]; then IDLE="green"; else IDLE="blue"; fi + + git clone "http://${INFRA_GIT_TOKEN}@34.31.145.131/neuron-technologies/infrastructure.git" \ + --depth=1 --branch=main /tmp/infra-update + + cd /tmp/infra-update + + DEPLOY_DIR="platform/k8s/neuron-mcp" + python3 -c " +import re, sys + +slot = sys.argv[1] +idle = sys.argv[2] + +def set_replicas(path, count): + with open(path) as f: + content = f.read() + content = re.sub(r'^( replicas: )\d+', r'\g<1>' + str(count), content, count=1, flags=re.MULTILINE) + with open(path, 'w') as f: + f.write(content) + print(f' {path}: replicas set to {count}') + +set_replicas(f'{DEPLOY_DIR}/deployment-{slot}.yaml', 1) +set_replicas(f'{DEPLOY_DIR}/deployment-{idle}.yaml', 0) +" "$SLOT" "$IDLE" + + git config user.email "ci@neurontechnologies.ai" + git config user.name "Neuron CI" + git add "${DEPLOY_DIR}/deployment-blue.yaml" "${DEPLOY_DIR}/deployment-green.yaml" + git diff --staged --quiet && { echo "No manifest changes needed"; exit 0; } + git commit -m "ci: neuron-mcp replica sync after blue-green swap to ${SLOT}" + git push origin main + echo "Infrastructure manifests updated: ${SLOT}=1, ${IDLE}=0" + - name: Verify deployment run: | SLOT="${{ steps.vars.outputs.slot }}"