name: Build Container on: workflow_call: inputs: prerelease: type: boolean description: Whether to create a prerelease tag default: false dry-run: type: boolean description: Whether to dry run the build and push default: false registry: type: string description: The registry to use required: true registry-user: type: string description: The username to use for the registry required: true registry-password: type: string description: The password to use for the registry required: true repo-name: type: string description: The name of the repository required: true tag: type: string description: The tag to use for the repository required: true context: type: string description: The context to use for the build default: . dockerfile: type: string description: The Dockerfile to use for the build default: Dockerfile jobs: build_and_push: name: Build and push strategy: matrix: # Prepared for future multi-arch support in the future, as soon as ACT has support for dynamic matrixes. arch: [amd64] runs-on: - ubuntu-latest - linux_${{ matrix.arch }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - uses: docker/login-action@371161bbe7024a29a25c5e19bfcbc0804fe9ad2c # v4.5.2 with: registry: ${{ inputs.registry }} username: ${{ inputs.registry-user }} password: ${{ inputs.registry-password }} - uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 with: context: ${{ inputs.context }} file: ${{ inputs.dockerfile }} platforms: linux/${{ matrix.arch }} push: ${{ inputs.dry-run == false || inputs.dry-run == 'false' }} provenance: false tags: | ${{ inputs.registry }}/${{ inputs.repo-name }}:${{ inputs.tag }}-${{ matrix.arch }} cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.repo-name }}:cache-${{ matrix.arch }} cache-to: type=registry,ref=${{ inputs.registry }}/${{ inputs.repo-name }}:cache-${{ matrix.arch }},mode=max create_manifest: name: Create manifest if: ${{ inputs.dry-run == false || inputs.dry-run == 'false' }} needs: - build_and_push runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: docker/login-action@371161bbe7024a29a25c5e19bfcbc0804fe9ad2c # v4.5.2 with: registry: ${{ inputs.registry }} username: ${{ inputs.registry-user }} password: ${{ inputs.registry-password }} - run: | docker manifest create ${{ inputs.registry }}/${{ inputs.repo-name }}:${{ inputs.tag }} \ ${{ inputs.registry }}/${{ inputs.repo-name }}:${{ inputs.tag }}-amd64 docker manifest push ${{ inputs.registry }}/${{ inputs.repo-name }}:${{ inputs.tag }}