Merge pull request #2 from dax-side/test-good-pr-1739543526 #11
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 VPS | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Deploy to VPS | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.VPS_IP }} | |
username: ${{ secrets.VPS_USERNAME }} | |
key: ${{ secrets.VPS_PRIVATE_KEY }} | |
script: | | |
# Navigate to your FastAPI app directory | |
cd ~/my_fastapi_project | |
git pull origin main # Pull the latest code from the main branch | |
# Activate the virtual environment and install dependencies | |
source venv/bin/activate | |
pip install -r requirements.txt | |
# Restart your FastAPI app (replace with your service name) | |
sudo systemctl restart fastapi-app | |
# Ensure Nginx is running and restart if necessary | |
if ! systemctl is-active --quiet nginx; then | |
sudo systemctl start nginx | |
sudo systemctl enable nginx | |
fi | |
# Reload Nginx configuration | |
sudo nginx -t && sudo systemctl reload nginx |