name: Approve stale lead maintainer PRs

on:
  push:
    branches:
      - approve-stale-lead-maintainer-prs
  schedule:
    # Run every six hours on weekdays to find stale lead maintainer PRs.
    - cron: "17 0,6,12,18 * * 1-5"
  workflow_dispatch:
    inputs:
      pull_request:
        description: Pull request number to review
        required: true
        type: number

permissions: {}

env:
  HOMEBREW_DEVELOPER: 1

defaults:
  run:
    shell: bash -euo pipefail {0}

jobs:
  approve:
    if: github.repository == 'Homebrew/brew'
    runs-on: ubuntu-latest
    permissions:
      checks: read
      contents: read
      issues: read
      pull-requests: write
      statuses: read
    env:
      HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }}
      PR_NUMBER: ${{ github.event.inputs.pull_request || '' }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Evaluate stale lead maintainer PRs
        run: ./bin/brew ruby -- .github/scripts/approve_stale_lead_maintainer_prs.rb
