Eng-Musa commited on
Commit
2efc78b
·
1 Parent(s): 8b4ea9c

add deplye yaml

Browse files
Files changed (1) hide show
  1. .github/workflows/deploy.yml +38 -0
.github/workflows/deploy.yml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy Python Chatbot Backend
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ deploy:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v4.2.2
15
+
16
+ - name: Setup SSH
17
+ uses: webfactory/ssh-agent@v0.9.1
18
+ with:
19
+ ssh-private-key: ${{ secrets.VPS_SSH_KEY }}
20
+
21
+ - name: Add server to known hosts
22
+ run: |
23
+ mkdir -p ~/.ssh
24
+ ssh-keyscan -H ${{ secrets.VPS_IP }} >> ~/.ssh/known_hosts
25
+
26
+ - name: Sync app files to server
27
+ run: |
28
+ REMOTE_SERVER="${{ secrets.VPS_USER }}@${{ secrets.VPS_IP }}"
29
+ rsync -avz --exclude='.git' --exclude='.env' --exclude='__pycache__' \
30
+ -e "ssh" ./ $REMOTE_SERVER:/home/ubuntu/app/
31
+
32
+ - name: Install dependencies and restart service
33
+ run: |
34
+ REMOTE_SERVER="${{ secrets.VPS_USER }}@${{ secrets.VPS_IP }}"
35
+ ssh $REMOTE_SERVER << 'EOF'
36
+ /home/ubuntu/venv/bin/pip install -q -r /home/ubuntu/app/requirements.txt && \
37
+ sudo systemctl restart chatbot-python.service
38
+ EOF