name: Docker Build

on:
  workflow_call:
    inputs:
      tag:
        required: true
        type: string

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - name: Default
            Dockerfile: Dockerfile
            suffix: ""
          - name: nvidia
            Dockerfile: Dockerfile-nvidia
            suffix: "-nvidia"

    steps:
    - name: Checkout Repository
      uses: actions/checkout@v3

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1

    - name: Login to DockerHub
      uses: docker/login-action@v1
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_TOKEN }}

    - name: Build and push
      uses: docker/build-push-action@v2
      with:
        context: .
        push: true
        tags: vexorian/dizquetv:${{ inputs.tag }}${{ matrix.suffix }}

    - name: Build and push nvidia
      uses: docker/build-push-action@v2
      with:
        context: .
        file: ${{ matrix.Dockerfile }}
        push: true
        tags: vexorian/dizquetv:${{ inputs.tag }}${{ matrix.suffix }}
