Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
renefs committed Feb 11, 2024
1 parent a6354fa commit b8394ee
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 88 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/deploy.yml

This file was deleted.

30 changes: 18 additions & 12 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,39 @@ name: Django CI

on:
push:
branches: [main, dev]
branches: [main, develop]
pull_request:
branches: [main, dev]
branches: [main, develop]

jobs:
build:
env:
DJANGO_ENV: test
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.10.8]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
- name: Install poetry
uses: abatilo/actions-poetry@v2
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install the project dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.dev.txt
mv backend/config/config.sample.py backend/config/config.py
sed -i -e "s/\/usr\/src\/data\/db.sqlite3/{{env.GITHUB_WORKSPACE}}\backend\/db.sqlite3/g" backend/config/config.py
mv .env.ci.sample .env
poetry install
- name: Run Tests
run: |
coverage run backend/manage.py test
- name: Upload coverage
poetry run coverage run backend/manage.py test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
37 changes: 37 additions & 0 deletions .github/workflows/docker-build-publish-backend-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Docker Build & Publish latest
on:
push:
branches:
- main

jobs:
build-and-publish:
name: Build and Publish Docker Image (latest)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

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

- name: Build and Push backend Docker Image
uses: docker/build-push-action@v5
with:
context: . # Path to your Dockerfile and other build context files
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
labels: |
org.opencontainers.image.source=https://github.com/bocabitlabs/${{ github.repository }}
37 changes: 37 additions & 0 deletions .github/workflows/docker-build-publish-backend-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Docker Build & Publish Backend tag
on:
release:
types:
- created

jobs:
build-and-publish:
name: Build and Publish Docker Image (tag)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

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

- name: Build and Push backend Docker Image (tag)
uses: docker/build-push-action@v5
with:
context: . # Path to your Dockerfile and other build context files
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.head_ref || github.ref_name }}
labels: |
org.opencontainers.image.source=https://github.com/bocabitlabs/${{ github.repository }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build & Publish latest
name: Docker Build & Publish Client latest
on:
push:
branches:
Expand All @@ -10,35 +10,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

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

- name: Build and Push backend Docker Image
uses: docker/build-push-action@v2
with:
context: . # Path to your Dockerfile and other build context files
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
- name: Build and Push client Docker Image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: . # Path to your Dockerfile and other build context files
file: docker.client.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}-client:latest
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.source=https://github.com/bocabitlabs/${{ github.repository }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build & Publish tag
name: Docker Build & Publish Client tag
on:
release:
types:
Expand All @@ -10,35 +10,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

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

- name: Build and Push backend Docker Image (tag)
uses: docker/build-push-action@v2
with:
context: . # Path to your Dockerfile and other build context files
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.head_ref || github.ref_name }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
- name: Build and Push client Docker Image (tag)
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: . # Path to your Dockerfile and other build context files
file: docker.client.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}-client:${{ github.head_ref || github.ref_name }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.source=https://github.com/bocabitlabs/${{ github.repository }}

0 comments on commit b8394ee

Please sign in to comment.