AI 평가가 끝난 시점에 S3에서 tmp → public으로 이동 #15
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: Backend Deploy | |
| on: | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: corretto | |
| java-version: 21 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build | |
| run: ./gradlew clean build -x test | |
| - name: Copy jar to EC2 | |
| run: | | |
| echo "${{ secrets.EC2_SSH_KEY }}" > key.pem | |
| chmod 600 key.pem | |
| scp -o StrictHostKeyChecking=no \ | |
| -i key.pem \ | |
| build/libs/demo-backend-0.0.1-SNAPSHOT.jar \ | |
| ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:/home/ec2-user/ | |
| rm -f key.pem | |
| - name: Restart app on EC2 | |
| run: | | |
| echo "${{ secrets.EC2_SSH_KEY }}" > key.pem | |
| chmod 600 key.pem | |
| ssh -o StrictHostKeyChecking=no \ | |
| -i key.pem \ | |
| ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF' | |
| # 기존 프로세스 종료 (정확한 JAR만) | |
| pkill -f demo-backend-0.0.1-SNAPSHOT.jar || true | |
| # 새 버전 실행 | |
| nohup java -jar /home/ec2-user/demo-backend-0.0.1-SNAPSHOT.jar \ | |
| --spring.profiles.active=prod \ | |
| > app.log 2>&1 & | |
| EOF | |
| rm -f key.pem |