name: 'Close stale issues and PRs'
on:
  workflow_dispatch:
  schedule:
    # 00:00:000 UTC
    - cron: '0 0 * * *'

permissions:
  issues: write
  pull-requests: write

jobs:
  stale:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
        with:
          # DEV: GitHub Actions have an API rate limit of 1000 operations per hour per repository
          #      This limit is shared across all actions
          operations-per-run: 200
          # DEV: Mark PR as stale after 30 days
          days-before-pr-stale: 30
          # DEV: Close stale PR after 1 day of no activity
          days-before-pr-close: 1
          days-before-issue-close: 90
          exempt-issue-labels: 'proposal'
          exempt-pr-labels: 'proposal'
          close-issue-message: |
            This issue has been automatically closed after a period of inactivity. If it's a
            feature request, it has been added to the maintainers' internal backlog and will be
            included in an upcoming round of feature prioritization. Please comment or reopen
            if you think this issue was closed in error.
          close-pr-message: |
            This pull request has been automatically closed after a period of inactivity.
            After this much time, it will likely be easier to open a new pull request with the
            same changes than to update this one from the base branch. Please comment or reopen
            if you think this pull request was closed in error.
