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@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
        id: generate-token
        with:
          creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
      - uses: actions/stale@5ebf00ea0e4c1561e9b43a292ed34424fb1d4578 # tag: v6.0.1
        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"
          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@cc6751b3b5e4edc5b9a4ad0a021ac455653b6dc8 # v1.0.0
        id: generate-token
        with:
          creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
      - uses: actions/stale@5ebf00ea0e4c1561e9b43a292ed34424fb1d4578 # tag: v6.0.1
        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.
