feat: 회원가입 이메일 인증 및 중복 확인 추가 #12
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: Java CI/CD with Docker and EC2 | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - "backend/**" | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Build with Gradle | |
| run: | | |
| chmod +x gradlew | |
| ./gradlew bootJar -x test | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: backend | |
| push: true | |
| tags: | | |
| jookyworld/prolog-backend:latest | |
| jookyworld/prolog-backend:${{ github.sha }} | |
| deploy: | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Copy docker-compose files to EC2 | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| source: "backend/docker-compose.yml,backend/docker-compose.prod.yml,backend/mysql" | |
| # EC2에서는 docker-compose.prod.yml만 사용 | |
| target: "~/app" | |
| strip_components: 1 | |
| - name: Deploy to EC2 via SSH | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| envs: IMAGE_TAG | |
| script: | | |
| cd ~/app | |
| export IMAGE_TAG=${{ github.sha }} | |
| sudo -E docker-compose -f docker-compose.prod.yml pull spring-app | |
| sudo -E docker-compose -f docker-compose.prod.yml up -d --remove-orphans | |
| sudo docker image prune -f |