Deploy to AWS EC2 #8
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 to AWS EC2 | |
| on: | |
| workflow_run: | |
| workflows: [Run CI] | |
| types: | |
| - completed | |
| jobs: | |
| deploy-backend: | |
| if: > | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.head_branch == 'main' && | |
| github.event.workflow_run.event == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Deploy on EC2 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| script: | | |
| cd feed-forward || exit 1 | |
| git pull origin main | |
| docker-compose -f docker-compose.yml -f docker-compose.prod.yml down | |
| docker rmi $(docker images -q) | |
| docker system prune -a | |
| docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build |