docs: update README, schema.json #238
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
name: CI/CD | |
on: push | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install requirements | |
run: pip install -r requirements.txt | |
- name: Lint Ruff | |
run: ruff check . | |
- name: Lint Flake8 | |
run: flake8 . | |
types: | |
runs-on: ubuntu-latest | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install requirements | |
run: pip install -r requirements.txt | |
- name: Check types | |
run: mypy . | |
test: | |
runs-on: ubuntu-latest | |
needs: [ lint, types ] | |
container: python:3.12.2-slim | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: ${{ secrets.DATABASE_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} | |
POSTGRES_DB: ${{ secrets.DATABASE_NAME }} | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
redis: | |
image: redis:7.2.5-alpine | |
ports: | |
- 6379:6379 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install requirements | |
run: pip install -r requirements.txt | |
- name: Run migrations | |
env: | |
DATABASE_NAME: ${{ secrets.DATABASE_NAME }} | |
DATABASE_USER: ${{ secrets.DATABASE_USER }} | |
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} | |
DATABASE_HOST: postgres | |
DATABASE_PORT: 5432 | |
DEBUG: ${{ secrets.DEBUG }} | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
run: python3 manage.py migrate | |
- name: Tests | |
env: | |
DATABASE_NAME: ${{ secrets.DATABASE_NAME }} | |
DATABASE_USER: ${{ secrets.DATABASE_USER }} | |
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} | |
DATABASE_HOST: postgres | |
DATABASE_PORT: 5432 | |
REDIS_HOST: ${{ secrets.REDIS_HOST }} | |
REDIS_PORT: ${{ secrets.REDIS_PORT }} | |
DEBUG: ${{ secrets.DEBUG }} | |
CORS_ALLOWED_ORIGINS: ${{ secrets.CORS_ALLOWED_ORIGINS }} | |
ALLOWED_HOSTS: ${{ secrets.ALLOWED_HOSTS }} | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
EMAIL_HOST: ${{ secrets.EMAIL_HOST }} | |
EMAIL_PORT: ${{ secrets.EMAIL_PORT }} | |
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }} | |
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }} | |
run: pytest . | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Copy repository contents via scp | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
port: ${{ secrets.PORT }} | |
key: ${{ secrets.SSHKEY }} | |
source: "." | |
target: "/var/www/mywebsite" | |
- name: Create .env file on remote server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
port: ${{ secrets.PORT }} | |
key: ${{ secrets.SSHKEY }} | |
script: | | |
cd /var/www/mywebsite | |
sudo rm -f .env | |
sudo touch .env | |
sudo chmod 666 .env | |
sudo cat <<EOF > .env | |
DEBUG=${{ secrets.DEBUG }} | |
CORS_ORIGIN_ALLOW_ALL=${{ secrets.CORS_ORIGIN_ALLOW_ALL }} | |
CORS_ALLOW_CREDENTIALS=${{ secrets.CORS_ALLOW_CREDENTIALS }} | |
CORS_ALLOWED_ORIGINS=${{ secrets.CORS_ALLOWED_ORIGINS }} | |
DOMAIN_NAME=${{ secrets.DOMAIN_NAME }} | |
ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }} | |
DATABASE_NAME=${{ secrets.DATABASE_NAME }} | |
DATABASE_USER=${{ secrets.DATABASE_USER }} | |
DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }} | |
DATABASE_HOST=${{ secrets.DATABASE_HOST }} | |
DATABASE_PORT=${{ secrets.DATABASE_PORT }} | |
RABBITMQ_DEFAULT_USER=${{ secrets.RABBITMQ_DEFAULT_USER }} | |
RABBITMQ_DEFAULT_PASS=${{ secrets.RABBITMQ_DEFAULT_PASS }} | |
REDIS_HOST=${{ secrets.REDIS_HOST }} | |
REDIS_PORT=${{ secrets.REDIS_PORT }} | |
SECRET_KEY=${{ secrets.SECRET_KEY }} | |
EMAIL_HOST=${{ secrets.EMAIL_HOST }} | |
EMAIL_PORT=${{ secrets.EMAIL_PORT }} | |
EMAIL_USE_SSL=${{ secrets.EMAIL_USE_SSL }} | |
EMAIL_HOST_USER=${{ secrets.EMAIL_HOST_USER }} | |
EMAIL_HOST_PASSWORD=${{ secrets.EMAIL_HOST_PASSWORD }} | |
EOF | |
- name: Executing remote command | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
port: ${{ secrets.PORT }} | |
key: ${{ secrets.SSHKEY }} | |
script: | | |
cd /var/www/mywebsite | |
docker-compose up -d --build |