name: 🕒 Handle Stale Issues

on:
  schedule:
    # Runs daily at 1:30 AM UTC (3:30 AM CEST - France time)
    - cron: "30 1 * * *"

jobs:
  stale-issues:
    name: 🗑️ Cleanup Stale Issues
    runs-on: ubuntu-24.04
    permissions:
      issues: write
      pull-requests: write

    steps:
      - name: 🔄 Mark/Close Stale Issues
        uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
        with:
          # Global settings
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          operations-per-run: 500  # Increase if you have >1000 issues
          log-level: debug

          # Issue configuration
          days-before-issue-stale: 90
          days-before-issue-close: 7
          stale-issue-label: "stale"
          exempt-issue-labels: "Roadmap v1,help needed,enhancement"

          # Notifications messages
          stale-issue-message: |
            ⏳ This issue has been automatically marked as **stale** because it has had no activity for 90 days.

            **Next steps:**
            - If this is still relevant, add a comment to keep it open
            - Otherwise, it will be closed in 7 days

            Thank you for your contributions! 🙌

          close-issue-message: |
            🚮 This issue has been automatically closed due to inactivity (7 days since being marked stale).

            **Need to reopen?**
            Click "Reopen" and add a comment explaining why this should stay open.

          # Disable PR handling
          days-before-pr-stale: -1
          days-before-pr-close: -1
