Refactor deploy script to remove containers and prune network #13
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 EC2 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - feature/rag-db-v2 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| sudo docker ps -aq | xargs -r sudo docker rm -f || true | |
| sudo docker network prune -f || true | |
| sudo rm -rf ~/backend | |
| git clone https://x-access-token:${{ secrets.MY_GITHUB_TOKEN }}@github.com/Amore-Innovation/backend.git ~/backend | |
| cd ~/backend | |
| sudo OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY }}" docker compose up -d --build --force-recreate |