name: release-tag

on:
  workflow_dispatch: # Manuelles Auslösen des Workflows
    inputs:
      image_tag:
        description: '2. Tag für das Docker-Image (außer latest) (z.B. v1.0.0)'
        required: true
        default: '0.2.0'

env:
  image_name: mysteryhelfer
  registry: gitea.tebarius.duckdns.org
  user: tebarius

jobs:
  release-image:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2

      - name: Login to Gitea
        uses: docker/login-action@v2
        with:
          registry: ${{ env.registry }}
          username: ${{ env.user }}
          password: ${{ secrets.DOCKER_PULL_TOKEN }}

      - name: Build and push
        run: |
          # Stelle sicher, dass Buildx aktiviert ist
          docker buildx create --use

          # Führe den Multiarch-Build aus und pushe das Image
          docker buildx build \
            --file ./Dockerfile \
            --platform linux/amd64,linux/arm64 \
            --tag ${{ env.registry }}/${{ env.user }}/${{ env.image_name }}:latest \
            --tag ${{ env.registry }}/${{ env.user }}/${{ env.image_name }}:${{ github.event.inputs.image_tag }} \
            --push ./
