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: - name: Free disk space uses: jlumbroso/free-disk-space@main with: tool-cache: false android: true dotnet: true haskell: true large-packages: true docker-images: true swap-storage: true - 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 platforms: linux/amd64,linux/arm64 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