name: "dependabot-automerge"

on:
  pull_request_target:
    types: [assigned, opened, synchronize, reopened]

permissions:
  pull-requests: write
  contents: write

jobs:
  automerge:
    runs-on: ubuntu-latest
    if: github.actor == 'dependabot[bot]'
    steps:
      - name: metadata
        id: metadata
        uses: dependabot/fetch-metadata@v1.3.6
        with:
          github-token: "${{ secrets.TOKEN }}"
      - name: merge
        id: merge
        if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}}
        run: gh pr merge --auto --merge "$PR_URL"
        env:
          PR_URL: ${{github.event.pull_request.html_url}}
          GITHUB_TOKEN: ${{secrets.TOKEN}}
