Skip to content

Add gunicorn server #39

Add gunicorn server

Add gunicorn server #39

Workflow file for this run

name: Python CI
on:
push:
branches:
- main
- develop
pull_request:
release:
types: [ released ]
jobs:
linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
test-app:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'requirements/*.txt'
- name: Install dependencies
run: |
pip install wheel
pip install -r requirements/dev.txt coveralls
env:
PIP_USE_MIRRORS: true
- name: Run mypy
run: mypy .
- name: Run tests and coverage
run: |
coverage run --source=$SOURCE_FOLDER -m pytest -rxXs
env:
SOURCE_FOLDER: app
- name: Send results to coveralls
continue-on-error: true # Ignore coveralls problems
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required for coveralls
docker-deploy:
runs-on: ubuntu-latest
needs:
- linting
- test-app
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || (github.event_name == 'release' && github.event.action == 'released')
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: docker/setup-buildx-action@v3
- name: Dockerhub login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy Master
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
file: docker/web/Dockerfile
push: true
tags: safeglobal/safe-auth-service:staging
platforms: |
linux/amd64
linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy Develop
if: github.ref == 'refs/heads/develop'
uses: docker/build-push-action@v6
with:
context: .
file: docker/web/Dockerfile
push: true
tags: safeglobal/safe-auth-service:develop
platforms: |
linux/amd64
linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy Tag
if: (github.event_name == 'release' && github.event.action == 'released')
uses: docker/build-push-action@v6
with:
context: .
file: docker/web/Dockerfile
push: true
tags: |
safeglobal/safe-auth-service:${{ github.event.release.tag_name }}
safeglobal/safe-auth-service:latest
platforms: |
linux/amd64
linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
autodeploy:
runs-on: ubuntu-latest
needs: [docker-deploy]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v4
- name: Deploy Staging
if: github.ref == 'refs/heads/main'
run: bash scripts/autodeploy.sh
env:
AUTODEPLOY_URL: ${{ secrets.AUTODEPLOY_URL }}
AUTODEPLOY_TOKEN: ${{ secrets.AUTODEPLOY_TOKEN }}
TARGET_ENV: "staging"
- name: Deploy Develop
if: github.ref == 'refs/heads/develop'
run: bash scripts/autodeploy.sh
env:
AUTODEPLOY_URL: ${{ secrets.AUTODEPLOY_URL }}
AUTODEPLOY_TOKEN: ${{ secrets.AUTODEPLOY_TOKEN }}
TARGET_ENV: "develop"