배포 준비#4 #7
Workflow file for this run
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: Spring Boot Deploy | |
| on: | |
| push: | |
| branches: [ deploy ] # main 브랜치 push 시 실행 | |
| 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: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Build with Gradle | |
| run: ./gradlew clean build -x test | |
| - name: Send to EC2 | |
| uses: appleboy/scp-action@v0.1.4 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| source: "build/libs/app-backend-0.0.1-SNAPSHOT.jar" | |
| target: "~/app" | |
| - name: Restart Spring Boot | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| script: | | |
| export $(cat ~/app/.env | xargs) | |
| pkill -f 'java.*.jar' || true | |
| nohup java -jar ~/app/*.jar > ~/app/log.txt 2>&1 & |