name: Update Stale Issues
on:
  schedule:
    # Run 1:24AM every night
    - cron: '24 1 * * *'
  workflow_dispatch:
permissions:
  issues: write
jobs:
  stale:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/stale@v6
        with:
          # Idle number of days before marking issues stale
          days-before-issue-stale: 365

          # Never mark PRs as stale
          days-before-pr-stale: -1

          # Idle number of days before closing stale issues
          days-before-issue-close: 30

          # Never close PRs
          days-before-pr-close: -1

          # Ignore issues with an assignee
          exempt-all-issue-assignees: true

          # Label to use when marking as stale
          stale-issue-label: needs-update

          stale-issue-message: >
            We've made a lot of changes to Certbot since this issue was opened. If you
            still have this issue with an up-to-date version of Certbot, can you please
            add a comment letting us know? This helps us to better see what issues are
            still affecting our users. If there is no activity in the next 30 days, this
            issue will be automatically closed.

          close-issue-message: >
            This issue has been closed due to lack of activity, but if you think it
            should be reopened, please open a new issue with a link to this one and we'll
            take a look.

          # Limit the number of actions per run. As of writing this, GitHub's
          # rate limit is 1000 requests per hour so we're still a ways off. See
          # https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limits-for-requests-from-github-actions.
          operations-per-run: 180
