Merge pull request #10 from Partition-app/feat/auto-assign-chore #9
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: Partition CI/CD | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build jar | |
| run: ./gradlew clean build -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@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/partition-spring:latest | |
| deploy: | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to EC2 via SSH | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_PRIVATE_KEY }} | |
| script: | | |
| cd /home/ubuntu/partition | |
| # 지금 푸시된 브랜치 기준으로 체크아웃 (main or develop) | |
| git fetch origin | |
| git checkout ${{ github.ref_name }} | |
| git pull origin ${{ github.ref_name }} | |
| # 최신 이미지 받아서 컨테이너 재시작 | |
| sudo docker compose pull | |
| sudo docker compose up -d |