name: "Triage stale pull requests"

on:
  schedule:
    - cron: "30 1 * * *"

jobs:
  stale-pull-requests:
    name: Triage stale pull requests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/stale@v8
        with:
          # docs - https://github.com/actions/stale
          # only triage pull requests
          days-before-issue-stale: -1
          days-before-issue-close: -1
          days-before-pr-stale: 30
          days-before-pr-close: 30
          ascending: true # start processing older pull requests first
          stale-pr-label: "pr:stale"
          stale-pr-message: >
            This pull request has been automatically marked as stale because it has not had activity in the last
            30 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status
            update now, ping for review, or re-open when it's ready. Thank you for your contributions!
          close-pr-message: >
            This pull request has been automatically closed because it has not had activity in the last 30 days.
            Please feel free to give a status update now, ping for review, or re-open when it's ready.
            Thank you for your contributions!

  stale-issues:
    name: Triage stale issues
    runs-on: ubuntu-latest
    steps:
      - uses: actions/stale@v8
        with:
          # docs - https://github.com/actions/stale
          # only triage issues
          days-before-issue-stale: 120

          # The idle number of days before closing the stale issues or the stale pull requests (due to the stale label).
          # The issues or the pull requests will be closed if the last update (based on GitHub issue field updated_at)
          # is older than the idle number of days.
          # Since adding the stale label will alter the last update date, we can calculate the number of days from
          # this date.
          #
          # NOTE: for now we will not close stale issues, simply triage labelling them as stale
          days-before-issue-close: -1
          days-before-pr-stale: -1
          days-before-pr-close: -1
          ascending: true # start processing older issues first
          stale-issue-label: "pr:stale"
          exempt-issue-labels: "not-stale"
          stale-issue-message: >
            This issue has been automatically marked as stale because it has not had activity in the last
            120 days.
          # close-issue-message: >
          #   This issue has been automatically closed because it has not had activity in the last 150 days.
