Update README.md #14
This file contains 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.yml | |
name: Django CI Pipeline | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
env: | |
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} | |
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
POSTGRES_DB: ${{ secrets.POSTGRES_DB }} | |
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }} | |
DJANGO_DEBUG: "True" | |
DJANGO_SECURE_SSL_REDIRECT: "False" | |
DJANGO_SECURE_HSTS_SECONDS: 0 | |
DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS: "False" | |
DJANGO_SECURE_HSTS_PRELOAD: "False" | |
DJANGO_SESSION_COOKIE_SECURE: "False" | |
DJANGO_CSRF_COOKIE_SECURE: "False" | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: ${{ runner.os }}-buildx- | |
- name: Create .env file | |
run: | | |
echo "DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}" >> .env | |
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> .env | |
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env | |
echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" >> .env | |
echo "POSTGRES_HOST=${{ secrets.POSTGRES_HOST }}" >> .env | |
- name: Build Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: false | |
load: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
- name: Start Docker Compose services | |
run: docker-compose up -d | |
- name: Run backend tests | |
run: docker-compose run web pytest | |
# Clean up Docker containers | |
- name: Shutdown | |
run: docker-compose down |