GithubHelp home page GithubHelp logo

bridgecrew-perf7 / django-deploy-github Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hecsall/django-deploy-github

0.0 0.0 0.0 68 KB

Testing Automated Github Actions (CI) to deploy a Django app to a VPS

Python 100.00%

django-deploy-github's Introduction

Code style: black

Django Deploy Github

This repository is meant to create and test a fully working Github CI that will deploy a Django app to a generic VPS over SSH.

This is a test project and it's still work in progress. Do NOT use this if you don't know what you are doing.

master and develop branches are protected.
Every modification will be made in branches named feature/<username>/<task-name>.
From those branches, a merge request will be opened to develop.

The Python linter for this project will be Flake8. The auto-formatter for python files will be Black with format on save enabled.

Setup Github Secrets

To work, this project relies on some Github Secrets, here's the list:

  • PROJECT_NAME: Name used for the main project folder creation on the remote VPS, and used to name configuration files related to this project. Use a lowercase name without spaces (like my_project_name).
  • DJANGO_APP_NAME: Name of the main django app (folder containing the settings.py file), used to locate the main django folder.
  • VPS_APPS_BASE_PATH: Base path where you store your webapps inside your VPS (like /home/username/web) WITHOUT trailing /.
  • VPS_HOST: IP of the VPS where code will be deployed
  • VPS_PORT: SSH port of the SSH service on the VPS (usually 22 but could be different)
  • VPS_SSH_KEY: Private Key (PEM) that the CI will use to connect to the VPS. You should generate it doing ssh-keygen -m PEM -t rsa -b 4096, then add to your VPS authorized_hosts the public key.
  • VPS_USERNAME: Username of the user that will be used to login into the VPS
  • SETTINGS_DB_HOST: Database host for Django
  • SETTINGS_DB_NAME: Database name for Django
  • SETTINGS_DB_PORT: Database port for Django
  • SETTINGS_DB_USER: Database user for Django
  • SETTINGS_DEBUG: Debug setting for Django (True/False)
  • SETTINGS_SECRET_KEY: Django Secret Key

Setup local development environment

Setup Python Virtual Environment, and install dependencies

# Create virtual environment
python3 -m venv venv

# Activate virtual environment
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Run black formatter from your terminal to auto fix all "auto-fixable" issues inside python files.

black --exclude=django/venv/ .

Test python files before pushing (if there are errors, the CI will fail and won't deploy anything).
Note: we use pflake8 because that will read flake8 configurations from the pyproject.toml file.

# From the root folder of the project
pflake8 --exclude=django/venv/ --count .

django-deploy-github's People

Contributors

dependabot[bot] avatar hecsall avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.