---
name: Stale

on:
  schedule:
    - cron: "30 0 * * *"
  workflow_dispatch:

# The reusable workflow authenticates as the ESPHome GitHub App, so GITHUB_TOKEN
# needs no permissions at all.
permissions: {}

jobs:
  stale:
    if: github.repository_owner == 'esphome'
    # No GITHUB_TOKEN permissions: the reusable workflow mints an ESPHome
    # GitHub App token so the labels, comments and closures come from
    # esphome[bot] instead of github-actions[bot].
    uses: esphome/workflows/.github/workflows/stale.yml@61fd37a044cad4e9aa4303027b2a61b6a34da855  # main
    secrets:
      ESPHOME_GITHUB_APP_PRIVATE_KEY: ${{ secrets.ESPHOME_GITHUB_APP_PRIVATE_KEY }}
    with:
      # Live only on dev: a workflow_dispatch from any other branch is a dry run
      dry-run: ${{ github.ref != 'refs/heads/dev' }}
      days-before-stale: 90
      days-before-close: 7
      stale-label: stale
      exempt-label: not-stale
      ignored-users: esphbot,codecov-commenter
      stale-pr-message: >
        There hasn't been any activity on this pull request recently. This
        pull request has been automatically marked as stale because of that
        and will be closed if no further activity occurs within 7 days.

        If you are the author of this PR, please leave a comment if you want
        to keep it open. Also, please rebase your PR onto the latest dev
        branch to ensure that it's up to date with the latest changes.

        Thank you for your contribution!
      stale-issue-message: >
        There hasn't been any activity on this issue recently. Due to the
        high number of incoming GitHub notifications, we have to clean some
        of the old issues, as many of them have already been resolved with
        the latest updates.

        Please make sure to update to the latest ESPHome version and
        check if that solves the issue. Let us know if that works for you by
        adding a comment 👍

        This issue has now been marked as stale and will be closed if no
        further activity occurs. Thank you for your contributions.
