name: Merge Event

on:
  pull_request:
    types:
      - closed

jobs:
  if_merged:
    # Forked repos can not access Mattermost secret.
    if: github.event.pull_request.merged == true && !github.event.pull_request.head.repo.fork
    runs-on: ubuntu-latest
    steps:
    - uses: mattermost/action-mattermost-notify@main
      with:
        MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_MERGE_WEBHOOK }}
        TEXT: >
          [${{ github.repository }}] |
          [${{ github.event.pull_request.title }}
          #${{ github.event.number }}](https://github.com/${{ github.repository }}/pull/${{ github.event.number }})
          was merged into main by ${{ github.actor }}
