# Adapted from vercel/next.js
name: "Stale issue handler"
on:
  workflow_dispatch:
  schedule:
    # This runs every day 20 minutes before midnight: https://crontab.guru/#40_23_*_*_*
    - cron: "40 23 * * *"

jobs:
  stale:
    runs-on: ubuntu-latest
    if: github.repository_owner == 'shadcn-ui'
    steps:
      - uses: actions/stale@v9
        id: issue-stale
        name: "Mark stale issues, close stale issues"
        with:
          repo-token: ${{ secrets.STALE_TOKEN }}
          ascending: true
          days-before-issue-close: 7
          days-before-issue-stale: 365
          days-before-pr-stale: -1
          days-before-pr-close: -1
          remove-issue-stale-when-updated: true
          stale-issue-label: "stale?"
          exempt-issue-labels: "roadmap,next"
          stale-issue-message: "This issue has been automatically marked as stale due to one year of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you. (This is an automated message)"
          close-issue-message: "This issue has been automatically closed due to one year of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding! (This is an automated message)"
          operations-per-run: 300
      - uses: actions/stale@v9
        id: pr-state
        name: "Mark stale PRs, close stale PRs"
        with:
          repo-token: ${{ secrets.STALE_TOKEN }}
          ascending: true
          days-before-issue-close: -1
          days-before-issue-stale: -1
          days-before-pr-close: 7
          days-before-pr-stale: 365
          remove-pr-stale-when-updated: true
          exempt-pr-labels: "roadmap,next,bug"
          stale-pr-label: "stale?"
          stale-pr-message: "This PR has been automatically marked as stale due to one year of inactivity. It will be closed in 7 days unless there’s further input. If you believe this PR is still relevant, please leave a comment or provide updated details. Thank you. (This is an automated message)"
          close-pr-message: "This PR has been automatically closed due to one year of inactivity. Thank you for your understanding! (This is an automated message)"
          operations-per-run: 300
