name: Docker Build & Push on: workflow_call: inputs: push: description: "Push image to GHCR" type: boolean required: true outputs: image-digest: description: "Pushed image digest (sha256:…)" value: ${{ jobs.docker.outputs.image-digest }} image-tags: description: "Comma-separated list of applied tags" value: ${{ jobs.docker.outputs.image-tags }} jobs: docker: name: Docker Build & Push runs-on: ubuntu-latest timeout-minutes: 20 outputs: image-digest: ${{ steps.build-push.outputs.digest }} image-tags: ${{ steps.meta.outputs.tags }} steps: - name: Checkout source uses: actions/checkout@v6 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Validate Dockerfile if: inputs.push == false uses: docker/build-push-action@v7 with: context: . file: ./Containerfile call: check - name: Log in to GHCR if: inputs.push == true uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Docker metadata if: inputs.push == true id: meta uses: docker/metadata-action@v6 with: images: ghcr.io/${{ github.repository }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=ref,event=branch type=ref,event=pr type=sha,prefix=sha- - name: Build and push image if: inputs.push == true id: build-push uses: docker/build-push-action@v7 with: context: . file: ./Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} provenance: false cache-from: type=gha cache-to: type=gha,mode=max