Skip to content

Commit c313a5b

Browse files
authored
Merge pull request #27 from cliffkoome/feature/cicd-pipeline
ci: add automated rsync deployment pipeline
2 parents 9df93c0 + e0a3e50 commit c313a5b

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Deploy Echo Reach to DigitalOcean
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
name: Sync Files and Build on VPS
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up SSH configuration
18+
uses: webfactory/ssh-agent@v0.9.0
19+
with:
20+
ssh-private-key: ${{ secrets.VPS_SSH_KEY }}
21+
22+
- name: Add VPS to Known Hosts
23+
run: |
24+
mkdir -p ~/.ssh
25+
ssh-keyscan -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
26+
27+
- name: Rsync files to VPS
28+
# The --exclude flags prevent rsync from uploading local bloat
29+
# AND prevents --delete from erasing your production .env or python venv
30+
run: |
31+
rsync -avz --delete \
32+
--exclude '.git' \
33+
--exclude '.github' \
34+
--exclude 'node_modules' \
35+
--exclude 'frontend/dist' \
36+
--exclude 'backend/.env' \
37+
--exclude 'tts-service/venv' \
38+
./ ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }}:/var/www/echo-reach/
39+
40+
- name: Execute Build & Restart Scripts on VPS
41+
uses: appleboy/ssh-action@v1.0.3
42+
with:
43+
host: ${{ secrets.VPS_HOST }}
44+
username: ${{ secrets.VPS_USER }}
45+
key: ${{ secrets.VPS_SSH_KEY }}
46+
script: |
47+
cd /var/www/echo-reach
48+
49+
echo "--- Modifying Frontend API URLs ---"
50+
sed -i 's|http://localhost:4000||g' frontend/src/App.jsx
51+
52+
echo "--- Building Frontend ---"
53+
cd frontend
54+
npm install
55+
npm run build
56+
cd ..
57+
58+
echo "--- Installing Backend Dependencies ---"
59+
cd backend
60+
npm install
61+
cd ..
62+
63+
echo "--- Updating Python TTS Dependencies ---"
64+
cd tts-service
65+
source venv/bin/activate
66+
pip install -r requirements.txt
67+
cd ..
68+
69+
echo "--- Restarting PM2 Processes ---"
70+
pm2 restart all
71+
pm2 save

0 commit comments

Comments
 (0)