Add github action for publishing docker image to the github container registry

This commit is contained in:
Yiorgis Gozadinos 2025-10-16 14:22:55 +03:00
parent d6cefb1ebc
commit 23b195c34c
No known key found for this signature in database

45
.github/workflows/docker-publish.yml vendored Normal file
View file

@ -0,0 +1,45 @@
name: Build & publish Docker image
on:
workflow_run:
workflows: ["Build & publish to pypi"]
types:
- completed
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from pyproject.toml
id: version
run: |
VERSION=$(grep -oP '^version = "\K[^"]+' pyproject.toml)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max