name: 'Issue and PR Maintenance'

on:
  schedule:
    - cron: '0 0 * * *'   # runs at midnight UTC
  workflow_dispatch:

permissions:
  issues: write
  pull-requests: write

jobs:
  close-stale:
    name: Close Stale Issues
    runs-on: ubuntu-24.04
    steps:
      - name: Close Stale Issues
        uses: actions/stale@v9
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

          # Messaging
          stale-issue-message: >
            👋 This issue has been automatically marked as stale due to inactivity.
            If this issue is still relevant, please comment to keep it open.
            Without activity, it will be closed in 7 days.

          close-issue-message: >
            🔒 This issue has been automatically closed due to prolonged inactivity.
            Feel free to open a new issue if you have further questions or concerns.

          # Timing
          days-before-issue-stale: 14
          days-before-issue-close: 7

          # Labels
          stale-issue-label: 'stale'
          remove-stale-when-updated: true
          only-issue-labels: 'awaiting-requester'

          # Exemptions
          exempt-assignees: true
          exempt-milestones: true