Skip to content

Commit

Permalink
Upgraded cicd (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysavary authored Mar 19, 2023
1 parent 6ce8f33 commit f5cf61d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 74 deletions.
43 changes: 4 additions & 39 deletions .github/workflows/build-deploy-production-docker.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,10 @@
name: Build and deploy a production docker image based on main branch

on:
push:
tags:
- 'v*.*.*'
tags: [ v*.*.* ]

jobs:
build-deploy-production-docker:
name: Build and deploy
environment: production
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/winds-mobi/winds-mobi-admin
tags: |
type=semver,pattern={{version}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}

- name: Update Watchtower containers
run: |
curl -H "Authorization: Bearer ${{ secrets.WATCHTOWER_HTTP_API_TOKEN }}" https://watchtower.winds.mobi/v1/update
uses: winds-mobi/winds-mobi-cicd/.github/workflows/build-deploy-production-docker.yaml@main
secrets:
WATCHTOWER_HTTP_API_TOKEN: ${{ secrets.WATCHTOWER_HTTP_API_TOKEN }}
36 changes: 5 additions & 31 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
name: Test project

on:
push:
branches:
- main
pull_request:
on: [ push, pull_request ]

jobs:
test-python:
name: Lint and test
runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.9"
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install python dependencies with poetry
run: |
pip install poetry
poetry install
- name: Run python linters
run: |
poetry run black --check .
poetry run flake8 .
- name: Run python tests
run: poetry run pytest
uses: winds-mobi/winds-mobi-cicd/.github/workflows/test-python.yaml@main
with:
python_version: 3.9.13
poetry_version: 1.3.2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt update; \
FROM base AS python

RUN apt update; \
apt --yes --no-install-recommends install build-essential crul libpq-dev
apt --yes --no-install-recommends install build-essential curl libpq-dev
RUN curl -sSL https://install.python-poetry.org | python - --version 1.3.2

COPY . .
Expand Down
20 changes: 19 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ redis = "4.3.4"
sentry-sdk = "1.17.0"
whitenoise = "6.2.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
black = "22.6.0"
flake8 = "5.0.4"
isort = "5.12.0"
pytest = "7.1.2"
python-dotenv = "^1.0.0"

Expand All @@ -40,3 +41,8 @@ build-backend = "poetry.core.masonry.api"
line-length = 120
force-exclude = '''
'''

[tool.isort]
profile = "black"
line_length = 120
skip_glob = ["**/migrations"]
2 changes: 1 addition & 1 deletion winds_mobi_admin/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import include, path

urlpatterns = [
path("admin/", admin.site.urls),
Expand Down

0 comments on commit f5cf61d

Please sign in to comment.