feat: Kafka yapılandırmasına commons bağımlılığı eklendi; ActivityEve… #22
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Activity Log Service CI/CD | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - "activity-log-service/**" | |
| - ".github/workflows/activity-log-service-ci-cd.yml" | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: "Environment to deploy to" | |
| required: true | |
| default: "prod" | |
| type: choice | |
| options: | |
| - prod | |
| - debug | |
| jobs: | |
| build-and-deploy: | |
| runs-on: self-hosted | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: "17" | |
| distribution: "temurin" | |
| - name: Cache Maven packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2 | |
| - name: Build with Maven | |
| run: | | |
| cd activity-log-service | |
| mvn clean package -DskipTests | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| with: | |
| platforms: arm64 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and Push Docker image | |
| id: docker_build | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: ./activity-log-service | |
| platforms: linux/arm64 | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/activity-log-service:latest-arm64 | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/activity-log-service:buildcache | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/activity-log-service:buildcache,mode=max | |
| - name: Deploy to VPS | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script_stop: true | |
| command_timeout: "10m" | |
| script: | | |
| echo "Starting deployment of Activity Log Service..." | |
| docker pull ${{ secrets.DOCKERHUB_USERNAME }}/activity-log-service:latest-arm64 | |
| docker stop activity-log-service || true | |
| docker rm activity-log-service || true | |
| # Debug ve prod modları için farklı container yapılandırması | |
| if [[ "${{ github.event.inputs.environment }}" == "debug" ]]; then | |
| # Debug modu container yapılandırması | |
| docker run -d \ | |
| --name activity-log-service \ | |
| --network craftpilot-network \ | |
| --restart unless-stopped \ | |
| -p 8095:8095 \ | |
| -p 5010:5010 \ | |
| -v /opt/craftpilot/gcp-credentials.json:/gcp-credentials.json:ro \ | |
| -e SPRING_PROFILES_ACTIVE=prod \ | |
| -e KAFKA_BOOTSTRAP_SERVERS=kafka:9092 \ | |
| -e EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://craftpilot:13579ada@eureka-server:8761/eureka/ \ | |
| -e HOSTNAME=activity-log-service \ | |
| -e GOOGLE_APPLICATION_CREDENTIALS=/gcp-credentials.json \ | |
| -e SPRING_SECURITY_USER_NAME=craftpilot \ | |
| -e SPRING_SECURITY_USER_PASSWORD=13579ada \ | |
| -e SPRING_CLOUD_GCP_PROJECT_ID=craft-pilot-ai \ | |
| -e REDIS_HOST=redis \ | |
| -e REDIS_PORT=6379 \ | |
| -e REDIS_PASSWORD=13579ada \ | |
| -e MANAGEMENT_ENDPOINTS_WEB_BASE_PATH=/actuator \ | |
| -e "MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=*" \ | |
| -e MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS=always \ | |
| -e "JAVA_OPTS=-XX:+UseContainerSupport -XX:MaxRAMPercentage=70.0 -XX:+UseG1GC -Djava.security.egd=file:/dev/./urandom -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5010" \ | |
| --health-cmd="curl -f http://localhost:8095/actuator/health || exit 1" \ | |
| --health-interval=30s \ | |
| --health-timeout=10s \ | |
| --health-retries=3 \ | |
| --health-start-period=60s \ | |
| ${{ secrets.DOCKERHUB_USERNAME }}/activity-log-service:latest-arm64 | |
| else | |
| # Prod modu container yapılandırması | |
| docker run -d \ | |
| --name activity-log-service \ | |
| --network craftpilot-network \ | |
| --restart unless-stopped \ | |
| -p 8095:8095 \ | |
| -v /opt/craftpilot/gcp-credentials.json:/gcp-credentials.json:ro \ | |
| -e SPRING_PROFILES_ACTIVE=prod \ | |
| -e KAFKA_BOOTSTRAP_SERVERS=kafka:9092 \ | |
| -e EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://craftpilot:13579ada@eureka-server:8761/eureka/ \ | |
| -e HOSTNAME=activity-log-service \ | |
| -e GOOGLE_APPLICATION_CREDENTIALS=/gcp-credentials.json \ | |
| -e SPRING_SECURITY_USER_NAME=craftpilot \ | |
| -e SPRING_SECURITY_USER_PASSWORD=13579ada \ | |
| -e SPRING_CLOUD_GCP_PROJECT_ID=craft-pilot-ai \ | |
| -e REDIS_HOST=redis \ | |
| -e REDIS_PORT=6379 \ | |
| -e REDIS_PASSWORD=13579ada \ | |
| -e MANAGEMENT_ENDPOINTS_WEB_BASE_PATH=/actuator \ | |
| -e "MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=*" \ | |
| -e MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS=always \ | |
| -e "JAVA_OPTS=-XX:+UseContainerSupport -XX:MaxRAMPercentage=70.0 -XX:+UseG1GC -Djava.security.egd=file:/dev/./urandom" \ | |
| --health-cmd="curl -f http://localhost:8095/actuator/health || exit 1" \ | |
| --health-interval=30s \ | |
| --health-timeout=10s \ | |
| --health-retries=3 \ | |
| --health-start-period=60s \ | |
| ${{ secrets.DOCKERHUB_USERNAME }}/activity-log-service:latest-arm64 | |
| fi | |
| echo "=== Waiting for service startup ===" | |
| max_attempts=15 | |
| counter=0 | |
| while [ $counter -lt $max_attempts ]; do | |
| echo "Health check attempt $((counter + 1))/$max_attempts" | |
| # Container durumu kontrolü | |
| if ! docker ps --filter "name=activity-log-service" --format '{{.Status}}' | grep -q "Up"; then | |
| echo "Container is not running. Checking logs..." | |
| docker logs activity-log-service | |
| exit 1 | |
| fi | |
| # Health check kontrolü (basitleştirilmiş) | |
| HEALTH_CHECK=$(curl -s http://localhost:8095/actuator/health || echo "FAILED") | |
| if echo "$HEALTH_CHECK" | grep -q '"status":"UP"'; then | |
| echo "✓ Service is healthy" | |
| echo "=== Deployment completed successfully ===" | |
| exit 0 | |
| fi | |
| echo "Waiting for service to start... ($((counter + 1))/$max_attempts)" | |
| sleep 10 | |
| counter=$((counter + 1)) | |
| done | |
| echo "=== Service failed to start - Debug Information ===" | |
| echo "Docker Status:" | |
| docker ps -a | grep activity-log-service | |
| echo "Container Logs (last 100 lines):" | |
| docker logs activity-log-service --tail 100 | |
| exit 1 |