MusAI / .github /workflows /deploy.yml
Eng-Musa's picture
.
b7d355d
Raw
History Blame Contribute Delete
1.09 kB
name: Deploy Python Chatbot Backend
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.1
with:
ssh-private-key: ${{ secrets.VPS_SSH_KEY }}
- name: Add server to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.VPS_IP }} >> ~/.ssh/known_hosts
- name: Sync app files to server
run: |
REMOTE_SERVER="${{ secrets.VPS_USER }}@${{ secrets.VPS_IP }}"
rsync -avz --exclude='.git' --exclude='.env' --exclude='__pycache__' \
-e "ssh" ./ $REMOTE_SERVER:/home/ubuntu/app/
- name: Install dependencies and restart service
run: |
REMOTE_SERVER="${{ secrets.VPS_USER }}@${{ secrets.VPS_IP }}"
ssh $REMOTE_SERVER << 'EOF'
/home/ubuntu/venv/bin/pip install -q -r /home/ubuntu/app/requirements.txt && \
sudo systemctl restart chatbot-python.service
EOF