name: Stale Issues and PRs

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

permissions:
  issues: write
  pull-requests: write

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

          # Issue 配置
          stale-issue-message: |
            这个 issue 已经 60 天没有活动了，将在 14 天后自动关闭。
            如果这个问题仍然存在，请留言说明情况。

            This issue has been inactive for 60 days and will be closed in 14 days.
            If this issue is still relevant, please leave a comment.
          close-issue-message: |
            由于长时间无活动，这个 issue 已被自动关闭。
            如需重新打开，请留言说明。

            This issue has been automatically closed due to inactivity.
            Please comment if you'd like to reopen it.
          days-before-issue-stale: 60
          days-before-issue-close: 14
          stale-issue-label: 'stale'
          exempt-issue-labels: 'pinned,security,enhancement,help wanted'

          # PR 配置
          stale-pr-message: |
            这个 PR 已经 30 天没有活动了，将在 7 天后自动关闭。
            如果你还在处理这个 PR，请更新一下。

            This PR has been inactive for 30 days and will be closed in 7 days.
            If you're still working on it, please update it.
          close-pr-message: |
            由于长时间无活动，这个 PR 已被自动关闭。
            如需继续，请重新打开或创建新的 PR。

            This PR has been automatically closed due to inactivity.
            Please reopen or create a new PR to continue.
          days-before-pr-stale: 30
          days-before-pr-close: 7
          stale-pr-label: 'stale'
          exempt-pr-labels: 'pinned,security,wip'

          # 其他配置
          operations-per-run: 100
          remove-stale-when-updated: true
          ascending: true
