name: Stale Issue Handler

on:
  schedule:
    - cron: '0 0 * * *'  # 每天运行一次
  workflow_dispatch:  # 手动触发

jobs:
  stale:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    steps:
      - uses: actions/stale@v9
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          # Issue settings
          stale-issue-message: |
            ⚠️ This issue has been inactive for 30 days.

            If this is still relevant, please add a comment; otherwise it will be closed in 7 days.
          close-issue-message: |
            🔒 This issue has been automatically closed due to inactivity.

            If this is still relevant, feel free to reopen or create a new issue.
          stale-issue-label: 'stale'
          days-before-issue-stale: 30
          days-before-issue-close: 7

          # PR settings
          stale-pr-message: |
            ⚠️ This PR has been inactive for 60 days.

            If this change is still needed, please update the code or add a comment; otherwise it will be closed in 7 days.
          close-pr-message: |
            🔒 This PR has been automatically closed due to inactivity.
          stale-pr-label: 'stale'
          days-before-pr-stale: 60
          days-before-pr-close: 7

          # 豁免标签
          exempt-issue-labels: 'pinned,security,enhancement'
          exempt-pr-labels: 'pinned,security'
