Include Tests #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/django-ci-cd.yml | |
| name: Django CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| test: | |
| name: Run Tests and Trigger Deploy | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: mydb | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| env: | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/mydb | |
| DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} | |
| DEBUG: 'False' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m venv venv | |
| source venv/bin/activate | |
| pip install -r requirements.txt | |
| - name: Run migrations | |
| run: | | |
| source venv/bin/activate | |
| python manage.py migrate | |
| - name: Collect static files | |
| run: | | |
| source venv/bin/activate | |
| python manage.py collectstatic --noinput | |
| - name: Run tests | |
| run: | | |
| source venv/bin/activate | |
| python manage.py test | |
| - name: Trigger Render Deploy | |
| if: success() | |
| run: | | |
| curl -X POST https://api.render.com/deploy/srv-d128dj6mcj7s73f40hp0?key=${{ secrets.RENDER_API_KEY }} |