name: Issue Management

on:
  schedule:
    - cron: "30 1 * * *"  # Daily at 1:30 AM UTC
  workflow_dispatch:

jobs:
  stale:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    
    steps:
      - name: Close stale issues
        uses: actions/stale@v9
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          days-before-issue-stale: 30
          days-before-issue-close: 7
          days-before-pr-stale: 30
          days-before-pr-close: 7
          stale-issue-label: stale
          stale-pr-label: stale
          close-issue-label: closed
          close-pr-label: closed
          stale-issue-message: This issue is stale and will be closed in 7 days
          stale-pr-message: This PR is stale and will be closed in 7 days
          close-issue-message: Closed as stale
          close-pr-message: Closed as stale
          exempt-issue-labels: pinned,security
          exempt-pr-labels: pinned,security
