name: "[Single] Send Message to Telegram"

on:
  workflow_dispatch:
    inputs:
      nightly:
        description: "Nightly"
        required: true
        type: boolean
        default: false

  workflow_call:
    inputs:
      nightly:
        description: "Nightly"
        required: true
        type: boolean
        default: false

jobs:
  telegram:
    name: Notify Telegram
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: latest

      - uses: pnpm/action-setup@v4
        name: Install pnpm
        with:
          run_install: false

      - name: Pnpm install
        run: pnpm i

      - name: Send Releases
        run: |
          if [ "${{ inputs.nightly }}" = "true" ]; then
            pnpm send-notify:nightly
          else
            pnpm send-notify
          fi
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
          TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
          TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
          TELEGRAM_TO: "@keikolog"
          TELEGRAM_TO_NIGHTLY: "@ClashNyanpasu"
