name: 'Close stale issues'
on:
  workflow_dispatch:
  schedule:
    # 1:30am every day
    - cron: '30 1 * * *'

permissions: {}

jobs:
  stale:
    runs-on: ubuntu-latest
    steps:
      - name: Generate GitHub App token
        uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
        id: generate-token
        with:
          creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
      - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # tag: v9.0.0
        with:
          repo-token: ${{ steps.generate-token.outputs.token }}
          days-before-stale: 90
          days-before-close: 30
          stale-issue-label: stale
          operations-per-run: 1750
          stale-issue-message: >
            This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
          close-issue-message: >
            This issue has been closed due to inactivity, and will not be monitored.  If this is a bug and you can reproduce this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue.
          exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:,status/confirmed,stale-exempt"
          only-pr-labels: not-a-real-label
  pending-repro:
    runs-on: ubuntu-latest
    if: ${{ always() }}
    needs: stale
    steps:
      - name: Generate GitHub App token
        uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
        id: generate-token
        with:
          creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
      - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # tag: v9.0.0
        with:
          repo-token: ${{ steps.generate-token.outputs.token }}
          days-before-stale: -1
          days-before-close: 10
          remove-stale-when-updated: false
          stale-issue-label: blocked/need-repro
          stale-pr-label: not-a-real-label
          operations-per-run: 1750
          close-issue-message: >
            Unfortunately, without a way to reproduce this issue, we're unable to continue investigation. This issue has been closed and will not be monitored further. If you're able to provide a minimal test case that reproduces this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue.
