Skip to content

added gunicorn to requirements #5

added gunicorn to requirements

added gunicorn to requirements #5

Workflow file for this run

name: Deploy Django API
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the code
- uses: actions/checkout@v3
# Step 2: Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Step 4: Run migrations and create superuser
- name: Run migrations and create superuser
run: |
source .venv/bin/activate
python manage.py migrate
python manage.py createsuperuser --email username@test.com --username username
# Step 5: Deploy to remote server
- name: Deploy to remote server
uses: easingthemes/ssh-deploy@v2.2.11
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: "/home/django/50v-backend"
with:
ARGS: "--delete"
SCRIPT_AFTER: |
source ~/.bashrc
cd /home/django/your-django-app-directory
source .venv/bin/activate
python manage.py runserver
systemctl restart gunicorn