name: Trigger Remote Build macOS on Release

on:
  release:
    types: [created]
  workflow_dispatch:
    inputs:
      release_tag:
        description: 'Release tag'
        required: true
        type: string

jobs:
  trigger-release:
    if: github.event_name == 'release'
    runs-on: ubuntu-latest
    steps:
      - name: Trigger FlashGBX Remote Build
        uses: benc-uk/workflow-dispatch@v1
        with:
          workflow: FlashGBX Remote Build
          token: ${{ secrets.FLASHGBX_MACOS_TOKEN }}
          repo: Cliffback/FlashGBX-macOS
          ref: main
          inputs: '{"create_release": "true", "latest_version": "${{ github.event.release.tag_name }}"}'
  trigger-manual:
    if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != ''
    runs-on: ubuntu-latest
    steps:
      - name: Trigger FlashGBX Remote Build
        uses: benc-uk/workflow-dispatch@v1
        with:
          workflow: FlashGBX Remote Build
          token: ${{ secrets.FLASHGBX_MACOS_TOKEN }}
          repo: Cliffback/FlashGBX-macOS
          ref: main
          inputs: '{"create_release": "true", "latest_version": "${{ github.event.inputs.release_tag }}"}'
