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

cache-mode: none
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

    cache-mode: write
    permissions:
      actions: write
      pull-requests: write

    steps:
      - uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 #v11.0.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