name: Notify Translations

on:
  pull_request_target:
    types:
      - labeled
      - closed
  workflow_dispatch:
    inputs:
      number:
        description: PR number
        required: true
      debug_enabled:
        description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
        required: false
        default: 'false'

env:
  UV_SYSTEM_PYTHON: 1

jobs:
  job:
    runs-on: ubuntu-latest
    permissions:
      discussions: write
    steps:
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      - uses: actions/checkout@v5
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.11"
      - name: Setup uv
        uses: astral-sh/setup-uv@v7
        with:
          version: "0.4.15"
          enable-cache: true
          cache-dependency-glob: |
            requirements**.txt
            pyproject.toml
      - name: Install Dependencies
        run: uv pip install -r requirements-github-actions.txt
      # Allow debugging with tmate
      - name: Setup tmate session
        uses: mxschmitt/action-tmate@v3
        if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
        with:
          limit-access-to-actor: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Notify Translations
        run: python ./scripts/notify_translations.py
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NUMBER: ${{ github.event.inputs.number || null }}
          DEBUG: ${{ github.event.inputs.debug_enabled || 'false' }}
