Skip to content

reports

reports #18

Workflow file for this run

name: Deploy to Hostinger VPS
on:
push:
branches:
- main # Trigger when changes are pushed to the 'main' branch
jobs:
deploy:
runs-on: ubuntu-latest # The job will run on an Ubuntu runner
steps:
- name: Checkout code
uses: actions/checkout@v2 # This step checks out your code from the repository
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # Use the appropriate Python version for your project
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt # Make sure you have a 'requirements.txt' in your project
- name: Set up SSH agent
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.HOSTINGER_SSH_PRIVATE_KEY }} # Use the private key from GitHub Secrets
- name: Deploy to VPS
run: |
ssh -o StrictHostKeyChecking=no root@147.93.102.113 << 'EOF'
cd /var/www/Community_Management # Navigate to your Django project directory
echo "Starting deployment..."
# Kill any process using port 80
sudo lsof -i :80 | awk 'NR>1 {print $2}' | xargs sudo kill -9 || true
echo "Killed any processes using port 80"
# Ensure virtual environment is set up
python3 -m venv venv
source venv/bin/activate # Activate virtual environment
# Handle Git conflicts
git reset --hard HEAD
git pull origin main
echo "Pulled latest code from GitHub"
# Install the dependencies from the updated code
pip install -r requirements.txt
# Run database migrations
python manage.py migrate
echo "Ran database migrations"
# Run the Django development server in the background (not recommended for production)
nohup python manage.py runserver 0.0.0.0:80 > server.log 2>&1 &
echo "Started Django development server"
EOF