Skip to content

Commit

Permalink
Update django.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jwjacobson authored Apr 3, 2024
1 parent c2e50f8 commit fff2e97
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ name: jazztunes CI and Deployment
on:
push:
branches: [ "main" ]

env:
ADMIN_USER_ID: ${{ secrets.ADMIN_USER_ID }}
ALLOWED_HOSTS: ${{ secrets.ALLOWED_HOSTS }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DEBUG: ${{ secrets.DEBUG }}
DEFAULT_FROM_EMAIL: ${{ secrets.DEFAULT_FROM_EMAIL }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
Expand All @@ -24,6 +23,22 @@ jobs:
matrix:
python-version: [3.11]

# Define service containers for running tests
services:
postgres:
image: postgres
env:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_DB: testdb
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -35,15 +50,14 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests


env:
# Set DATABASE_URL for Django to connect to the test database
DATABASE_URL: postgres://testuser:testpass@localhost:5432/testdb
run: |
pytest
- name: Deploy to Heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
git fetch --unshallow || true
git push https://heroku:[email protected]/${{ secrets.HEROKU_APP_NAME }}.git HEAD:main -f

0 comments on commit fff2e97

Please sign in to comment.