name: 'Close stale issues and PRs'
on:
  schedule:
  - cron: '30 1 * * *'

permissions:
    # contents: write # only for delete-branch option
    issues: write
    pull-requests: write
    contents: write

jobs:
  stale:
    runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-small
    steps:
      - uses: actions/stale@v8
        with:
          # Issues
          days-before-issue-stale: -1 # Deactivate stale issues
          days-before-issue-close: -1 # Deactivate stale issues

          # PR
          days-before-pr-stale: 30
          days-before-pr-close: 7
          stale-pr-message: 'PR has had no activity for 30 days. What is blocking it? Is there anything you can do to help move it forward? Without action it will be closed in 7 days.'
          close-pr-message: 'Closing stale PR as no activity for 7 days'
          delete-branch: true
