Skip to content

Update GitHub Actions workflow for Docker builds #346

Update GitHub Actions workflow for Docker builds

Update GitHub Actions workflow for Docker builds #346

Workflow file for this run

name: docker-compose-actions-workflow
on:
push:
branches:
- master
tags:
- "v*"
# Necessario per pushare su GHCR
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
# Build quando pushi su branch (es. master)
build_branch:
if: github.ref_type == 'branch'
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./compose/local/django/Dockerfile
context: ./compose/local/django
image: ghcr.io/ldo-cert/orochi_django
- dockerfile: ./compose/local/dask/Dockerfile
context: ./compose/local/dask
image: ghcr.io/ldo-cert/orochi_worker
- dockerfile: ./compose/local/nginx/Dockerfile
context: ./compose/local/nginx
image: ghcr.io/ldo-cert/orochi_nginx
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: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (branch) 🚀
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ matrix.image }}:latest
${{ matrix.image }}:${{ github.sha }}
# Build quando pushi un tag (v*)
build_tag:
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./compose/local/django/Dockerfile
context: ./compose/local/django
image: ghcr.io/ldo-cert/orochi_django
- dockerfile: ./compose/local/dask/Dockerfile
context: ./compose/local/dask
image: ghcr.io/ldo-cert/orochi_worker
- dockerfile: ./compose/local/nginx/Dockerfile
context: ./compose/local/nginx
image: ghcr.io/ldo-cert/orochi_nginx
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: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (tagged release) 🏷️
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Pubblica anche il tag versione (es. v1.2.3)
tags: |
${{ matrix.image }}:latest
${{ matrix.image }}:${{ github.sha }}
${{ matrix.image }}:${{ github.ref_name }}