when: branch: [main, high-performance] event: push matrix: SERVICE: - gateway - users - companies - job_seekers - customers - payments - employees - photographers - makeup_artists - tutors - developers - video_editors - graphic_designers - social_media_managers - fitness_trainers - catering_services - ugc_content_creators - cron steps: - name: detect-changes image: alpine/git commands: - apk add --no-cache bash - | #!/bin/bash set -e # Get changed files from last commit CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD || echo "") # Convert matrix SERVICE to path format SERVICE_PATH=$(echo "${SERVICE}" | tr '_' '-') # Check if shared crates changed (triggers all services) SHARED_CHANGED=false if echo "$CHANGED_FILES" | grep -q "^crates/"; then SHARED_CHANGED=true echo "⚠️ Shared crates changed - will build all services" fi # Check if this specific service changed SERVICE_CHANGED=false if echo "$CHANGED_FILES" | grep -q "^apps/${SERVICE_PATH}/"; then SERVICE_CHANGED=true echo "✅ Service ${SERVICE} has code changes" fi # Create marker file and exit with appropriate code if [ "$SHARED_CHANGED" = "true" ] || [ "$SERVICE_CHANGED" = "true" ]; then echo "SHOULD_BUILD=true" >> ${CI_ENV} echo "🚀 Will build ${SERVICE}" exit 0 else echo "SHOULD_BUILD=false" >> ${CI_ENV} echo "⏭️ Skipping ${SERVICE} - no changes detected" # Exit with code 78 to skip subsequent steps for this service exit 78 fi - name: build image: woodpeckerci/plugin-docker-buildx:5.0.0 settings: registry: ghcr.io repo: ghcr.io/traceworks2023/nxtgauge-rust-${SERVICE} context: . dockerfile: Dockerfile.optimized build_args: - SERVICE_NAME=${SERVICE} tags: - ${CI_COMMIT_SHA} - latest - high-performance-latest username: from_secret: GHCR_USERNAME password: from_secret: GHCR_TOKEN platforms: linux/amd64 - name: deploy image: bitnami/kubectl:latest environment: KUBE_CONFIG: from_secret: kube_config commands: - | #!/bin/bash set -e # Setup kubeconfig mkdir -p ~/.kube echo "$KUBE_CONFIG" | base64 -d > ~/.kube/config chmod 600 ~/.kube/config # Convert service name to Kubernetes deployment name DEPLOYMENT_NAME=$(echo "${SERVICE}" | tr '_' '-') NAMESPACE="nxtgauge" echo "🚀 Deploying ${SERVICE} (deployment: nxtgauge-rust-${DEPLOYMENT_NAME})..." # Trigger rolling restart to pick up new image kubectl rollout restart deployment/nxtgauge-rust-${DEPLOYMENT_NAME} -n ${NAMESPACE} # Wait for rollout to complete (with timeout) echo "⏳ Waiting for rollout to complete..." kubectl rollout status deployment/nxtgauge-rust-${DEPLOYMENT_NAME} -n ${NAMESPACE} --timeout=300s echo "✅ ${SERVICE} deployed successfully!" # Show deployment status kubectl get deployment/nxtgauge-rust-${DEPLOYMENT_NAME} -n ${NAMESPACE} - name: notify-success image: alpine:latest commands: - echo "✅ Pipeline completed successfully for ${SERVICE}" when: status: success - name: notify-failure image: alpine:latest commands: - echo "❌ Pipeline failed for ${SERVICE}" - echo "Check logs for details" when: status: failure