name: Maintenance

on:
  # So that PRs touching the same files as the push are updated
  push:
    branches:
      - master
      - next
  # So that the `dirtyLabel` is removed if conflicts are resolved
  # Could put too much strain on rate limit
  # If we hit the rate limit too often remove this event
  pull_request_target:
    branches:
      - master
      - next
    types: [synchronize]

permissions: {}

jobs:
  main:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - name: check if prs are dirty
        uses: eps1lon/actions-label-merge-conflict@1b1b1fcde06a9b3d089f3464c96417961dde1168 # v3.0.2
        with:
          dirtyLabel: 'PR: out-of-date'
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          commentOnDirty: 'This pull request has conflicts, please resolve those before we can evaluate the pull request.'
          retryAfter: 130
          retryMax: 10
