This document explains how to configure GitHub Actions secrets and variables for deploying the Yastvo Django application.
Go to Settings → Secrets and variables → Actions → Variables and add:
-
APP_NAME(default:cafe)- The application name used for service naming and directories
-
SUBDOMAIN(default:cafe)- The subdomain for your domain (e.g.,
cafeforcafe.yourdomain.com)
- The subdomain for your domain (e.g.,
Go to Settings → Secrets and variables → Actions → Secrets and add:
-
ORACLE_SSH_KEY- Your private SSH key for accessing the VM
- Format: Complete private key including
-----BEGINand-----ENDlines
-
ORACLE_USER- SSH username for the VM (e.g.,
ubuntuor your username)
- SSH username for the VM (e.g.,
-
ORACLE_HOST- VM IP address or hostname
-
DOMAIN_NAME- Your domain name (e.g.,
example.com) - Combined with SUBDOMAIN to form full domain (e.g.,
cafe.example.com)
- Your domain name (e.g.,
-
EMAIL- Email address for Let's Encrypt SSL certificates
DB_PASSWORD- Password for the MariaDB database user
- Will be used to create
cafe_dbdatabase withcafe_user
BACKEND_ENV_VARS- Complete
.envfile content for Django application - Example format:
SECRET_KEY=your-django-secret-key-here DEBUG=False ALLOWED_HOSTS=cafe.example.com DB_ENGINE=django.db.backends.mysql DB_NAME=cafe_db DB_USER=cafe_user DB_PASSWORD=your-db-password-here DB_HOST=localhost DB_PORT=3306 DJANGO_SUPERUSER_USERNAME=admin DJANGO_SUPERUSER_EMAIL=admin@example.com DJANGO_SUPERUSER_PASSWORD=your-admin-password-here # Add any other environment variables your app needs
- Complete
Before running the workflow, ensure:
- ✅ Domain A record points to your VM IP address
- ✅ VM has ports 80 and 443 open in firewall
- ✅ SSH access is configured and working
- ✅ All secrets and variables are set in GitHub
- ✅ The VM has sufficient disk space and resources
Since this VM already hosts another application (dormed), the deployment scripts are designed to:
- Reuse existing infrastructure: MariaDB, Nginx, Certbot are already installed
- Create separate resources: New database, new Gunicorn service, new Nginx site config
- Avoid conflicts: Each app runs its own Gunicorn service on its own socket
The deployment process uses three scripts:
-
provision_infrastructure.sh
- Checks and installs system dependencies if needed
- Creates new MariaDB database for this app
- Configures SSL certificate for the domain
- Sets up Nginx site configuration
-
setup_gunicorn.sh
- Creates systemd service for Gunicorn
- Configures service to run as a daemon
-
deploy_app.sh
- Extracts application code
- Sets up Python virtual environment
- Installs dependencies
- Runs migrations and collectstatic
- Compiles translations
- Restarts Gunicorn service
If deployment fails, SSH into the VM and check:
# Check Gunicorn service status
sudo systemctl status cafe.service
# View service logs
sudo journalctl -u cafe.service -n 50
# Check Nginx configurationsudo nginx -t
# View Nginx error logs
sudo tail -f /var/log/nginx/error.log
# Check if database was created
sudo mysql -e "SHOW DATABASES LIKE 'cafe_db';"If you need to deploy manually:
# SSH into the VM
ssh user@your-vm-ip
# Navigate to project directory
cd ~/cafe
# Activate virtual environment
source venv/bin/activate
# Pull latest changes (if using git directly)
git pull origin main
# Install dependencies
pip install -r requirements.txt
# Run migrations
python manage.py migrate
# Collect static files
python manage.py collectstatic --noinput
# Restart service
sudo systemctl restart cafe.service