name: Broadcast Release To Discord

on:
  release:
    types: [published]

permissions:
  contents: read

jobs:
  announce:
    name: Announce On Discord
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 22

      - name: Send release embed
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
          DISCORD_RELEASE_EMOJI: ${{ vars.DISCORD_RELEASE_EMOJI || '<:quake4:1425986174941397105>' }}
          DISCORD_RELEASE_MENTIONS: ${{ vars.DISCORD_RELEASE_MENTIONS || '<@&1425985498693898260> <@&1390287267276525628>' }}
          DISCORD_FEEDBACK_CHANNEL: ${{ vars.DISCORD_FEEDBACK_CHANNEL || '<#1509926146018513077>' }}
          DISCORD_RELEASE_AVATAR_URL: ${{ vars.DISCORD_RELEASE_AVATAR_URL || 'https://raw.githubusercontent.com/themuffinator/OpenQ4/main/assets/img/avatar.png' }}
        shell: bash
        run: |
          set -euo pipefail
          node .github/scripts/announce-release-discord.mjs
