Merge pull request #138 from My-Medi/develop #51
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: Initial Deployment for MyMedi | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Java | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Build JAR | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew bootJar -x test | |
| - name: Upload to EC2 | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_KEY }} | |
| source: "." | |
| target: "~/my_medi_main" | |
| - name: SSH and deploy | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_KEY }} | |
| script: | | |
| cd ~/my_medi_main | |
| if [ ! -f .env ]; then | |
| echo "❌ .env 파일이 존재하지 않아 배포를 중단합니다." | |
| exit 1 | |
| fi | |
| docker-compose down --volumes --remove-orphans || true | |
| docker-compose up -d --build |