name: Stale

on:
  schedule:
    - cron: "17 3 * * *"
  workflow_dispatch:

permissions: {}

jobs:
  stale:
    permissions:
      issues: write
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1
        id: app-token
        with:
          app-id: "2729701"
          private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
      - name: Mark stale issues and pull requests
        uses: actions/stale@v9
        with:
          repo-token: ${{ steps.app-token.outputs.token }}
          days-before-issue-stale: 7
          days-before-issue-close: 5
          days-before-pr-stale: 5
          days-before-pr-close: 3
          stale-issue-label: stale
          stale-pr-label: stale
          exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale
          exempt-pr-labels: maintainer,no-stale
          operations-per-run: 500
          exempt-all-assignees: true
          remove-stale-when-updated: true
          stale-issue-message: |
            This issue has been automatically marked as stale due to inactivity.
            Please add updates or it will be closed.
          stale-pr-message: |
            This pull request has been automatically marked as stale due to inactivity.
            Please add updates or it will be closed.
          close-issue-message: |
            Closing due to inactivity.
            If this is still an issue, please retry on the latest OpenClaw release and share updated details.
            If you are absolutely sure it still happens on the latest release, open a new issue with fresh repro steps.
          close-issue-reason: not_planned
          close-pr-message: |
            Closing due to inactivity.
            If you believe this PR should be revived, post in #pr-thunderdome-dangerzone on Discord to talk to a maintainer.
            That channel is the escape hatch for high-quality PRs that get auto-closed.
