Dev > Main 브랜치 병합 #169
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
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
| name: Java CD with Gradle | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - name: execute remote ssh & deploy backend server | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.REMOTE_SSH_HOST }} | |
| username: ${{ secrets.REMOTE_SSH_USERNAME }} | |
| key: ${{ secrets.REMOTE_SSH_KEY }} | |
| port: ${{ secrets.REMOTE_SSH_PORT }} | |
| script: | | |
| cd /home/ec2-user/backend/ | |
| git pull origin main | |
| chmod +x ./gradlew | |
| ./gradlew build | |
| pid=$(lsof -ti:8080) | |
| if [ -n "$pid" ]; then | |
| kill -9 $pid | |
| fi | |
| docker stop redis || true | |
| docker rm redis || true | |
| docker run -d --name redis -p 6379:6379 redis | |
| docker stop devpals-container || true | |
| docker rm devpals-container || true | |
| docker build -t devpals-app . | |
| docker run -d -p 8080:8080 --name devpals-container --link redis devpals-app |