name: 'Close stale issues and PRs'
on:
  schedule:
    # Once every day at midnight UTC
    - cron: "0 0 * * *"
  workflow_dispatch: # Allow to run workflow manually
  issue_comment: # Run workflow on comments

jobs:
  stale:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    steps:
      - name: Mark/Close Stale Issues and Pull Requests 🗑️
        uses: actions/stale@v9.0.0
        with:
          repo-token: ${{ secrets.STALE_ACTION_PAT }}
          days-before-stale: 60
          days-before-close: 7
          stale-issue-message: >
            This issue has been automatically marked as stale because it has not had
            recent activity. It will be closed if no further activity occurs.
          stale-pr-message: >
            This pull request has been automatically marked as stale because it has not had
            recent activity. It will be closed if no further activity occurs.
          exempt-issue-labels: "pinned,security,enhancement,investigating,neverstale"
          exempt-pr-labels: "pinned,security,enhancement,investigating,neverstale"
          stale-issue-label: "stale"
          stale-pr-label: "stale"
          exempt-draft-pr: "true"
          close-issue-reason: "not_planned"
          operations-per-run: "250"
          ascending: "true"
          #DRY-RUN
          debug-only: "false"
