name: Build and Deploy Platform on: push: branches: [main, master] workflow_dispatch: env: # Push via internal Harbor registry (no creds needed from runner pod) REGISTRY_INTERNAL: harbor-registry.cloudhost.svc.cluster.local:5000 REGISTRY: registry.abrban.com BACKEND_IMAGE: abrban/cloudhost-backend FRONTEND_IMAGE: abrban/cloudhost-frontend jobs: build-push-deploy: runs-on: abrban-kaniko steps: - name: Checkout uses: actions/checkout@v4 - name: Set image tag shell: bash run: | SHA="${GITHUB_SHA:-$(git rev-parse HEAD)}" echo "IMAGE_TAG=$(date +%Y%m%d-%H%M)-${SHA:0:8}" >> "$GITHUB_ENV" - name: Build backend (Kaniko) run: | /kaniko/executor \ --context=./backend \ --dockerfile=./backend/Dockerfile \ --destination="${REGISTRY_INTERNAL}/${BACKEND_IMAGE}:${IMAGE_TAG}" \ --insecure \ --skip-tls-verify - name: Build frontend (Kaniko) run: | /kaniko/executor \ --context=./frontend \ --dockerfile=./frontend/Dockerfile \ --build-arg=NEXT_PUBLIC_API_URL=https://api.abrban.com \ --destination="${REGISTRY_INTERNAL}/${FRONTEND_IMAGE}:${IMAGE_TAG}" \ --insecure \ --skip-tls-verify - name: Update GitOps values shell: bash run: | sed -i "s|tag: \"[^\"]*\"|tag: \"${IMAGE_TAG}\"|g" gitops/platform/values-abrban.yaml git config user.email "ci@abrban.com" git config user.name "Gitea Actions" git add gitops/platform/values-abrban.yaml git diff --cached --quiet || git commit -m "ci: deploy platform ${IMAGE_TAG}" - name: Push GitOps update shell: bash env: GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git remote set-url origin "https://oauth2:${GITEA_TOKEN}@git.abrban.com/abrban/cloud-host.git" git push origin HEAD:main