Skip to content

added gitigntoer

added gitigntoer #6

Workflow file for this run

name: Django + Supabase CI/CD
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
pip install pytest pytest-django pytest-cov black flake8 isort
- name: Run linting
run: |
cd backend
black --check .
flake8 .
isort --check .
- name: Run tests
env:
DJANGO_SECRET_KEY: test_secret_key
DJANGO_DEBUG: True
DB_ENGINE: django.db.backends.postgresql
DB_NAME: test_db
DB_USER: postgres
DB_PASSWORD: postgres
DB_HOST: localhost
DB_PORT: 5432
SUPABASE_URL: https://example.supabase.co
SUPABASE_ANON_KEY: test_anon_key
SUPABASE_SERVICE_ROLE_KEY: test_service_role_key
SUPABASE_JWT_SECRET: test_jwt_secret
run: |
cd backend
pytest --cov=. --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./backend/coverage.xml
fail_ci_if_error: false
deploy:
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${DOCKERHUB_USERNAME}
password: ${DOCKERHUB_TOKEN}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile
push: true
tags: ${DOCKERHUB_USERNAME}/django-supabase:latest
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# Example deployment to a server using SSH
# Uncomment and configure as needed
# - name: Deploy to server
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SSH_HOST }}
# username: ${{ secrets.SSH_USERNAME }}
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# script: |
# cd /path/to/deployment
# docker-compose pull
# docker-compose up -d