File tree Expand file tree Collapse file tree 2 files changed +70
-5
lines changed
Expand file tree Collapse file tree 2 files changed +70
-5
lines changed Original file line number Diff line number Diff line change 1+ name : Django CI with Docker
2+
3+ on :
4+ push :
5+ branches : [ "main", "master" ]
6+ pull_request :
7+ branches : [ "main", "master" ]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+
13+ services :
14+ postgres :
15+ image : postgres:15
16+ env :
17+ POSTGRES_DB : test_db
18+ POSTGRES_USER : test_user
19+ POSTGRES_PASSWORD : test_pass
20+ ports :
21+ - 5432:5432
22+ options : >-
23+ --health-cmd="pg_isready"
24+ --health-interval=10s
25+ --health-timeout=5s
26+ --health-retries=5
27+
28+ env :
29+ DEBUG : 1
30+ SECRET_KEY : test-secret
31+ POSTGRES_DB : test_db
32+ POSTGRES_USER : test_user
33+ POSTGRES_PASSWORD : test_pass
34+ POSTGRES_HOST : localhost
35+ POSTGRES_PORT : 5432
36+ ALLOWED_HOSTS : localhost,127.0.0.1
37+
38+ steps :
39+ - name : ⬇️ Checkout código
40+ uses : actions/checkout@v4
41+
42+ - name : 🐍 Set up Python
43+ uses : actions/setup-python@v5
44+ with :
45+ python-version : 3.11
46+
47+ - name : 📦 Instalar dependencias
48+ run : |
49+ python -m pip install --upgrade pip
50+ pip install -r requirements.txt
51+
52+ - name : 🐘 Esperar PostgreSQL
53+ run : |
54+ until pg_isready -h localhost -p 5432; do
55+ echo "Esperando postgres..."
56+ sleep 2
57+ done
58+
59+ - name : 🧩 Migraciones
60+ run : |
61+ python manage.py migrate
62+
63+ - name : 🧪 Ejecutar tests
64+ run : |
65+ pytest
Original file line number Diff line number Diff line change 7171DATABASES = {
7272 'default' : {
7373 'ENGINE' : 'django.db.backends.postgresql' ,
74- 'NAME' : os .environ . get ( "DB_NAME" ),
75- 'USER' : os .environ . get ( "DB_USER" ),
76- 'PASSWORD' : os .environ . get ( "DB_PASSWORD" ),
77- 'HOST' : os .environ . get ( "DB_HOST" ),
78- 'PORT' : os .environ . get ( "DB_PORT" ),
74+ 'NAME' : os .getenv ( 'POSTGRES_DB' , 'postgres' ),
75+ 'USER' : os .getenv ( 'POSTGRES_USER' , 'postgres' ),
76+ 'PASSWORD' : os .getenv ( 'POSTGRES_PASSWORD' , 'postgres' ),
77+ 'HOST' : os .getenv ( 'POSTGRES_HOST' , 'db' ),
78+ 'PORT' : os .getenv ( 'POSTGRES_PORT' , '5432' ),
7979 }
8080}
8181
You can’t perform that action at this time.
0 commit comments