...

Django based website deployed using GitHub Actions

How to personal blog Django based, Dockerized, deployable by GitHub Actions CI/CD


Repositories


 

Content delivery - blog features


  • PostgreSQL based content -> posts, projects, metadata
  • Feature any post or project to main page
  • Publish, draft or withdrawn any post or project from site
  • Add any user with restricted rights or full rights to deliver content
  • Adding published post or project to webpage sitemap
  • Minify uploaded images to save bandwidth and speed up page loading

 

Project overview


Backend is based on Django 5. Honestly page is running since ~2019 so main thing which I dis is upgrade to version 5 and dockerize NGINX, Postgres and Django istself. All of the backend behaviour stays the same and have not so many issues with upgrade. Below you can find some of backed functionalities with 'how to' explanation.

Automatic creation of so called secret key

Basically script is called before server start. If script find out any key exists, it will do nothing. Main purpose of that is maximize automation for newly deployed  server.

Feature any post or project to main page with chronological order

I thought it is good idea to highlight some of the entries to main page. That's why 'featuring' came in. By one checkbox you can put any entry to main page. Entries came in with chronological order.

Publish, draft or withdrawn any post or project from site

This feature is done by filtering database object which contains status choice in it's model.

Minify uploaded images

To speed up page I decided to minify some images, especially if images are only used as thubnail of an entry. I wrote simple function called on every post or project creation (on save/update event). It uses Pillow library to resize original freshly uploaded image.

CI/CD using GitHub Actions


Current CI/CD implementation is performing tests - actually builds all of the containers and after successfull job, code is deployed to remote server via SSH.