From fb84bc596f1de24e5d8f62a6914d1b6ce24ab64f Mon Sep 17 00:00:00 2001 From: DrCBeatz Date: Fri, 29 Mar 2024 17:40:28 -0400 Subject: [PATCH] update django-ci.yml --- .github/workflows/django-ci.yml | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/django-ci.yml b/.github/workflows/django-ci.yml index 9dfc7b4..20ccdf5 100644 --- a/.github/workflows/django-ci.yml +++ b/.github/workflows/django-ci.yml @@ -32,28 +32,41 @@ jobs: steps: - uses: actions/checkout@v2 - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - - name: Log in to Docker Hub - uses: docker/login-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + 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 + echo "MDB_PRO_KEY=${{ secrets.MDB_PRO_KEY }}" >> .env - - name: Build and push Docker images + - name: Build Docker image uses: docker/build-push-action@v2 with: context: . - push: true - tags: user/app:latest + 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 exec web pytest + run: docker-compose run web pytest - name: Add MDB API Key run: docker-compose exec web python manage.py addapikey