name: Create discord thread when a PR is opened, react with green checkmark when PR is merged

on:
  pull_request:
    types:
      - opened
      - ready_for_review
      - closed

jobs:
  notify_discord_when_pr_opened:
    if: (github.event.pull_request.draft == false) && (github.event.action == 'opened' || github.event.action == 'ready_for_review')
    uses: ./.github/workflows/shareable-discord-notification.yml
    with:
      PR_TITLE: ${{ github.event.pull_request.title }}
      PR_URL: ${{ github.event.pull_request.html_url }}
      PR_AUTHOR: ${{ github.event.pull_request.user.login }}
      PR_STATUS: "opened"
      PR_NUMBER: ${{ github.event.pull_request.number }}
      DISCORD_CHANNEL_ID: "1372204995868491786"
      DISCORD_GUILD_ID: "930051556043276338"
    secrets:
      DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_PR_REVIEWS_WEBHOOK }}
      DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_AI_BOT_TOKEN }}

  merge_success_emoji:
    if: github.event.action == 'closed'
    uses: ./.github/workflows/shareable-discord-notification.yml
    with:
      PR_STATUS: "merged"
      DISCORD_CHANNEL_ID: "1372204995868491786"
      DISCORD_GUILD_ID: "930051556043276338"
      PR_NUMBER: ${{ github.event.pull_request.number }}
    secrets:
      DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_AI_BOT_TOKEN }}
