.github/workflows/auto_deployment.yaml #56
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
| # main에 대한 pull_request가 closed될 때 workflow를 실행 | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| types: | |
| - closed | |
| workflow_dispatch: #수동 실행도 가능하도록 | |
| inputs: | |
| logLevel: | |
| description: 'Log level' | |
| required: true | |
| default: 'warning' | |
| type: choice | |
| options: | |
| - info | |
| - warning | |
| - debug | |
| # ssh로 접속하여 새로운 버전 배포 | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| # pr의 결과가 merged인 경우, 혹은 수동 트리거인 경우만 job 실행 | |
| if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' | |
| steps: | |
| # ssh로 EC2 접속 | |
| - name: Connect EC2 by SSH | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_KEY }} | |
| script: | | |
| ${{ secrets.AUTHORIZATION }} | |
| lsof -t -i:${{ secrets.APPLICATION_PORT }} | xargs -r kill && cd ${{ secrets.PROJECT_PATH }} || true | |
| git fetch && git pull | |
| git submodule update --remote --merge | |
| cp -r -f ./server-private/src/* ./src/ | |
| ./gradlew clean build -x test | |
| rm -f nohup.out | |
| { nohup java -jar ${{ secrets.APPLICATION_PATH }} > nohup.out 2>&1 & } | |
| sleep 5 && exit 0 |