name: Build image on: workflow_call: inputs: context: required: true type: string image_name: required: true type: string jobs: build: runs-on: ubuntu-latest permissions: contents: read packages: write concurrency: group: image-${{ inputs.image_name }}-${{ github.ref }} cancel-in-progress: true steps: - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Buildx uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - name: Log in to GHCR uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Generate image metadata id: meta uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: images: ghcr.io/${{ github.repository_owner }}/${{ inputs.image_name }} tags: | type=raw,value=latest,enable={{is_default_branch}} type=sha,format=long - name: Build and push image uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 with: context: ${{ inputs.context }} platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha,scope=${{ inputs.image_name }} cache-to: type=gha,mode=max,scope=${{ inputs.image_name }} provenance: mode=max sbom: true