This repository was archived by the owner on Jan 11, 2026. It is now read-only.
[HOTFIX] 회원 탈퇴 시 발생하는 IntegrityConstraintViolationException 해결 #94
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: CD with Gradle | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| types: | |
| - closed | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest # ubuntu 최신 버전에서 script를 실행 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: "adopt" | |
| - name: Set Sentry auth token | |
| run: | | |
| echo "export SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> $GITHUB_ENV | |
| - name: Make application.yml | |
| run: | | |
| mkdir -p src/main/resources | |
| echo "${{ secrets.PROPERTIES }}" > src/main/resources/application-prod.yml | |
| - name: Build with Gradle | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew clean build -x test | |
| - name: Docker build & push to docker repo | |
| run: | | |
| docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
| docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }} . | |
| docker push ${{ secrets.DOCKER_REPO }} | |
| - name: Deploy to server | |
| uses: appleboy/ssh-action@master | |
| id: deploy | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.KEY }} | |
| script: | | |
| # Docker 이미지를 최신 상태로 가져오기 | |
| sudo docker pull ${{ secrets.DOCKER_REPO }}:latest | |
| # 서버의 현재 환경 확인 (블루 / 그린) | |
| ENV_COLOR=$(curl --silent --fail https://www.api-spot.store/spot/current-env || echo "none") | |
| if [[ "$ENV_COLOR" == "blue" || "$ENV_COLOR" == "none" ]]; then | |
| # 블루 서버가 실행 중이거나 아무 서버도 돌아가고 있지 않다면 그린 서버를 실행 | |
| sudo docker-compose -f docker-compose.yml up -d --no-deps web-green | |
| sleep 75 | |
| # 그린 서버가 정상적으로 작동하는지 확인 (예: HTTP 상태 코드 200 확인) | |
| if curl --silent --fail http://localhost:8081; then | |
| echo "Green server is working correctly." | |
| # Nginx를 Green 서버로 전환 | |
| sudo sed -i 's/8080/8081/' /etc/nginx/sites-available/api-spot.store | |
| sudo systemctl restart nginx | |
| # 기존 서버 종료 | |
| sudo docker-compose -f docker-compose.yml stop web-blue | |
| else | |
| echo "Green server is not responding correctly. Exiting." | |
| exit 1 | |
| fi | |
| elif [[ "$ENV_COLOR" == "green" ]]; then | |
| # 그린 서버가 실행 중이면 블루 서버를 실행 | |
| sudo docker-compose -f docker-compose.yml up -d --no-deps web-blue | |
| sleep 75 | |
| # 블루 서버가 정상적으로 작동하는지 확인 | |
| if curl --silent --fail http://localhost:8080; then | |
| echo "Blue server is working correctly." | |
| # Nginx를 Blue 서버로 전환 | |
| sudo sed -i 's/8081/8080/' /etc/nginx/sites-available/api-spot.store | |
| sudo systemctl restart nginx | |
| # 기존 서버 종료 | |
| sudo docker-compose -f docker-compose.yml stop web-green | |
| else | |
| echo "Blue server is not responding correctly. Exiting." | |
| exit 1 | |
| fi | |
| else | |
| echo "Unable to determine current environment, exiting." | |
| exit 1 | |
| fi |