Update default.conf #107
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: Deploy to EC2 | |
| on: | |
| push: | |
| branches: [deploy] # deploy 브랜치에 push될 때만 실행됨 | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Build JAR | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew build -x test | |
| - name: Set up Docker | |
| 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 | |
| run: | | |
| docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/yourapp:latest . | |
| docker push ${{ secrets.DOCKERHUB_USERNAME }}/yourapp:latest | |
| - name: SSH Deploy (run deploy.sh in EC2) | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.DEPLOY_KEY }} | |
| script: | | |
| cd ~/app | |
| git reset --hard | |
| git pull origin deploy | |
| chmod +x deploy.sh | |
| ./deploy.sh |