name: 'Build docker on-demand'
on:
  workflow_dispatch:
    inputs:
      tag:
        description: 'docker container tag'
        required: true
        type: string
        default: 'dev'

jobs:
  docker:
    name: Docker Image Build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        platform:
          - linux/amd64
          - linux/arm64
          - linux/arm/v7
          - linux/arm/v8
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Docker meta for TAG
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=raw,value=${{ inputs.tag }}

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v6
        with:
          context: .
          file: Dockerfile
          push: true
          platforms: linux/amd64
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}