name: Stale Issue Cron
on:
  schedule:
    # Every day at midnight
    - cron: "0 0 * * *"
  workflow_dispatch:
jobs:
  stale:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    steps:
      # v5.1.0 has a weird bug that makes stalebot add then remove its own label
      # https://github.com/actions/stale/pull/775
      - uses: actions/stale@v7.0.0
        with:
          stale-issue-label: "stale"
          stale-pr-label: "stale"
          # Pull Requests become stale more quickly due to merge conflicts.
          # Also, we promote minimizing WIP.
          days-before-pr-stale: 7
          days-before-pr-close: 3
          stale-pr-message: >
            This Pull Request is becoming stale. In order to minimize WIP, 
            prevent merge conflicts and keep the tracker readable, I'm going
            close to this PR in 3 days if there isn't more activity.
          stale-issue-message: >
            This issue is becoming stale. In order to keep the tracker readable
            and actionable, I'm going close to this issue in 7 days if there 
            isn't more activity.
          # Upped from 30 since we have a big tracker and was hitting the limit.
          operations-per-run: 60
          # Start with the oldest issues, always.
          ascending: true
