Skip to content

Django with PostgreSQL #162

Django with PostgreSQL

Django with PostgreSQL #162

name: Django with PostgreSQL
on:
pull_request:
paths:
- "samples/django-with-postgres/**"
- ".github/workflows/django-with-postgres.yml"
schedule:
# Schedule: Runs at 9:00 AM and 1:00 PM Asia/Tokyo time (UTC+9) on weekdays (Monday to Friday).
- cron: "0 0,4 * * mon-fri"
jobs:
document:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: django_sample
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install django psycopg2-binary
- name: Install PostgreSQL 17 client
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-client-17
- name: Apply Django migrations
run: |
cd samples/django-with-postgres/django_sample
python manage.py migrate
- name: Extract schema
env:
PGPASSWORD: postgres
run: |
cd samples/django-with-postgres
pg_dump -h localhost -p 5432 -U postgres -d django_sample --schema-only > schema.sql
- name: Generate ER Diagrams
run: npx @liam-hq/cli erd build --format postgres --input samples/django-with-postgres/schema.sql