News Intelligent CD - Deploy to AWS EC2 #7
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: News Intelligent CD - Deploy to AWS EC2 | |
| on: | |
| workflow_run: | |
| # CI 성공 시 수행 | |
| workflows: | |
| - "News Intelligent CI" | |
| types: | |
| - completed | |
| jobs: | |
| deploy: | |
| if: ${{github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| # EC2에 배포 | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{secrets.EC2_SERVER_IP}} | |
| username: ${{secrets.EC2_USERNAME}} | |
| key: ${{secrets.EC2_PRIVATE_KEY}} | |
| script: | | |
| cd ~/${{secrets.REPOSITORY_PATH}} | |
| docker-compose down --remove-orphans | |
| docker pull ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPOSITORY}}:latest | |
| docker-compose up -d |