name: Close stale PRs
on:
  schedule:
    - cron: "0 0 * * *" # Runs every day at midnight

jobs:
  stale:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/stale@v9
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          days-before-pr-stale: 180 # 6 months before warning
          days-before-pr-close: 365 # Closed after 12 months
          stale-pr-label: "stale"
          stale-pr-message: "Hi! This PR has been inactive for 6 months. If it's still relevant, please update it to let us know you’d like to keep it open 😊"
          close-pr-message: "This PR has been automatically closed after 12 months of inactivity."
          days-before-issue-stale: -1 # Issues are never stale
          days-before-issue-close: -1 # Issues are never closed
          remove-stale-when-updated: true
