name: 'Close stale issues and PRs'
on:
  schedule:
    # Run every day at 1:14 UTC
    - cron: '14 1 * * *'
  workflow_dispatch:

jobs:
  stale:
    runs-on: ubuntu-latest
    permissions:
      actions: write
      issues: write
      pull-requests: write
    steps:
      - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639
        with:
          # Issues configuration
          stale-issue-message: >
            This issue has been automatically marked as stale because it has not had any activity in the last 6 months.
            It will be closed in 30 days if there is no further activity.
            
            
            If the issue is waiting for a reply from maintainers, feel free to ping them as a reminder.
            If it is waiting and has no comments yet, feel free to ping `@spack/spack-releasers` or simply leave a comment saying this should not be marked stale.
            This will also reset the issue's stale state.
            
            
            Thank you for your contributions!
          close-issue-message: >
            This issue was closed because it had no activity for 30 days after being marked stale.
            If you feel this is in error, please feel free to reopen this issue.
          stale-issue-label: 'stale'
          any-of-issue-labels: 'build-error,unreproducible,question,documentation,environments'
          exempt-issue-labels: 'pinned,triage,impact-low,impact-medium,impact-high'

          # Pull requests configuration
          stale-pr-message: >
            This pull request has been automatically marked as stale because it has not had any activity in the last 6 months. 
            It will be closed in 30 days if there is no further activity.
            
            
            If the pull request is waiting for a reply from reviewers, feel free to ping them as a reminder.
            If it is waiting and has no assigned reviewer, feel free to ping `@spack/spack-releasers` or simply leave a comment saying this should not be marked stale.
            This will reset the pull request's stale state.
            
            
            To get more eyes on your pull request, you can post a link in the #pull-requests channel of the Spack Slack.
            
            Thank you for your contributions!
          close-pr-message: >
            This pull request was closed because it had no activity for 30 days after being marked stale.
            If you feel this is in error, please feel free to reopen this pull request.
          stale-pr-label: 'stale'
          any-of-pr-labels: 'new-package,update-package'
          exempt-pr-labels: 'pinned'

          # General configuration
          ascending: true
          operations-per-run: 1000
          remove-stale-when-updated: true
          enable-statistics: true
          days-before-stale: 180
          days-before-close: 30
