# This workflow is centrally managed in https://github.com/asyncapi/.github/
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo

# Purpose of this workflow is to allow people to merge PR without a need of maintainer doing it. If all checks are in place (including maintainers approval) - JUST MERGE IT!
name: Automerge For Humans

on:
  pull_request_target:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked

jobs:
  automerge-for-humans:
    if: github.event.pull_request.draft == false && (github.event.pull_request.user.login != 'asyncapi-bot' || github.event.pull_request.user.login != 'dependabot[bot]' || github.event.pull_request.user.login != 'dependabot-preview[bot]') #it runs only if PR actor is not a bot, at least not a bot that we know
    runs-on: ubuntu-latest
    steps:
      - name: Automerge PR
        uses: pascalgn/automerge-action@v0.14.3
        env:
          GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"
          MERGE_LABELS: "!do-not-merge,ready-to-merge"
          MERGE_METHOD: "squash"
          MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})"
          MERGE_RETRIES: "20"
          MERGE_RETRY_SLEEP: "30000"