백엔드 서비스 계정 수정 #5
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 Backend | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'backend/**' | |
| workflow_dispatch: | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Check SERVER_IP | |
| run: echo "SERVER_IP = ${{ secrets.SERVER_IP }}" | |
| - name: Grant execute permission for gradlew | |
| run: | | |
| cd backend | |
| chmod +x gradlew | |
| - name: Build with Gradle | |
| run: | | |
| cd backend | |
| ./gradlew build -x test | |
| - name: Upload JAR to server | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.SERVER_IP }} | |
| username: ${{ secrets.SERVER_USER }} | |
| password: ${{ secrets.SERVER_PASSWORD }} | |
| source: "backend/build/libs/*.jar" | |
| target: "/root/TUK-cbu-manage/backend/build/libs" | |
| - name: Restart Docker Compose | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SERVER_IP }} | |
| username: ${{ secrets.SERVER_USER }} | |
| password: ${{ secrets.SERVER_PASSWORD }} | |
| script: | | |
| cd /root/TUK-cbu-manage/DevOps | |
| docker-compose -f docker-compose.prod.yml up --build -d |