Merge pull request #29 from cliffkoome/feature/frontend-update-api #3
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 Echo Reach to DigitalOcean | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| name: Sync Files and Build on VPS | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up SSH configuration | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.VPS_SSH_KEY }} | |
| - name: Add VPS to Known Hosts | |
| run: | | |
| mkdir -p ~/.ssh | |
| ssh-keyscan -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts | |
| - name: Rsync files to VPS | |
| # The --exclude flags prevent rsync from uploading local bloat | |
| # AND prevents --delete from erasing your production .env or python venv | |
| run: | | |
| rsync -avz --delete \ | |
| --exclude '.git' \ | |
| --exclude '.github' \ | |
| --exclude 'node_modules' \ | |
| --exclude 'frontend/dist' \ | |
| --exclude 'backend/.env' \ | |
| --exclude 'tts-service/venv' \ | |
| ./ ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }}:/var/www/echo-reach/ | |
| - name: Execute Build & Restart Scripts on VPS | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USER }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| script: | | |
| cd /var/www/echo-reach | |
| echo "--- Modifying Frontend API URLs ---" | |
| sed -i 's|http://localhost:4000||g' frontend/src/App.jsx | |
| echo "--- Building Frontend ---" | |
| cd frontend | |
| npm install | |
| npm run build | |
| cd .. | |
| echo "--- Installing Backend Dependencies ---" | |
| cd backend | |
| npm install | |
| cd .. | |
| echo "--- Updating Python TTS Dependencies ---" | |
| cd tts-service | |
| source venv/bin/activate | |
| pip install -r requirements.txt | |
| cd .. | |
| echo "--- Restarting PM2 Processes ---" | |
| pm2 restart all | |
| pm2 save |