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

permissions: {}

jobs:
  stale:
    # As this action runs on a schedule, only run it in the FreeTubeApp/FreeTube repository to avoid unnecessary GitHub Actions usage/billing in forks.
    # If a fork does need this workflow, they can change this condition in their fork to include their repository.
    if: github.repository == 'FreeTubeApp/FreeTube'

    runs-on: ubuntu-slim

    permissions:
      actions: write
      pull-requests: write

    steps:
      - uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f #v10.2.0
        with:
          stale-pr-message: 'This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
          close-pr-message: 'This PR was closed because it has been stalled for 14 days with no activity.'
          days-before-pr-stale: 14
          days-before-pr-close: 14
          stale-pr-label: 'PR: stale'
          exempt-pr-labels: 'PR: WIP'

          # actions/stale doesn't have a way of running only on pull requests
          # so set the issue thresholds to -1 so it at least doesn't try to label or close them
          days-before-stale: -1
          days-before-close: -1
