name: build-docker

on:
  workflow_dispatch:
  release:
    types: [published]

jobs:
  build:
    if: ${{ github.repository_owner == 'mltframework' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build and push to Docker Hub
        uses: docker/build-push-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
          repository: mltframework/melt
          tag_with_ref: true

      - name: Push to GitHub Packages
        uses: docker/build-push-action@v1
        with:
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: docker.pkg.github.com
          repository: mltframework/mlt/melt
          tag_with_ref: true
