fix : 그룹 생성 후 order 정보를 반환하지 않는 문제 해결 #44
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: CI/CD for Spring Boot + MySQL with Docker Compose | |
| on: | |
| push: | |
| branches: [ "main", "order-service/main" ] | |
| pull_request: | |
| branches: [ "main", "order-service/main" ] | |
| env: | |
| SERVICE_NAME: order-service # 예: order-service | |
| DOCKER_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest | |
| EC2_HOST: ${{ secrets.EC2_HOST }} | |
| EC2_SSH_USER: kmj02dev | |
| PRIVATE_KEY: ${{ secrets.EC2_SSH_PRIVATE_KEY }} | |
| TIMEZONE: Asia/Seoul | |
| DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| PROJECT_PATH: /home/kmj02dev/delivery-system/order-service # 예: /home/ec2-user/delivery-system/order-service | |
| APPLICATION: ${{ secrets.APPLICATION }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| environment: order-service | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Set up application.properties | |
| run: echo "${{ env.APPLICATION }}" > "${{ env.SERVICE_NAME }}/src/main/resources/application.properties" | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x ${{ env.SERVICE_NAME }}/gradlew | |
| - name: Build Spring Boot Application | |
| working-directory: ${{ env.SERVICE_NAME }} | |
| run: ./gradlew build | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ env.DOCKER_USERNAME }} | |
| password: ${{ env.DOCKER_TOKEN }} | |
| - name: Build Docker Image | |
| run: docker build -t ${{ env.DOCKER_IMAGE }} ./${{ env.SERVICE_NAME }} | |
| - name: Push Docker Image | |
| run: docker push ${{ env.DOCKER_IMAGE }} | |
| deploy-to-ec2: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' | |
| needs: build-and-push | |
| environment: order-service | |
| steps: | |
| - name: Deploy to EC2 via SSH | |
| uses: appleboy/ssh-action@v0.1.6 | |
| with: | |
| host: ${{ env.EC2_HOST }} | |
| username: ${{ env.EC2_SSH_USER }} | |
| key: ${{ env.PRIVATE_KEY }} | |
| script: | | |
| cd ${{ env.PROJECT_PATH }} | |
| sudo docker compose pull | |
| sudo docker compose down --rmi all | |
| sudo docker compose up -d |