Deploy to AWS EC2 #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 to AWS EC2 | |
| on: | |
| workflow_run: | |
| workflows: [Build CI] | |
| types: | |
| - completed | |
| jobs: | |
| deploy: | |
| 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: Print Trigger Info | |
| run: | | |
| echo "Workflow event: ${{ github.event.workflow_run.event }}" | |
| echo "Head branch: ${{ github.event.workflow_run.head_branch }}" | |
| - 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 |