# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests

on:
  schedule:
  - cron: '0 0 * * *' # Run every day at midnight

jobs:
  stale:
    if: ${{ github.repository == 'kubeflow/manifests' }}
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write

    steps:
    - uses: actions/stale@v5
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        days-before-stale: 60
        days-before-close: 21
        # The message that will be added as a comment to the issues
        # when the stale workflow marks it automatically as stale with a label.
        stale-issue-message: >
          This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
        # The message that will be added as a comment to the issues
        # when the stale workflow closes it automatically after being stale for too long.
        close-issue-message: >
          This issue has been automatically closed because it has not had recent activity. Please comment "/reopen" to reopen it.
        stale-issue-label: lifecycle/stale
        # Exclude them from being marked as stale
        exempt-issue-labels: lifecycle/frozen,enhancement,good first issue
        # The message that will be added as a comment to the pull requests
        # when the stale workflow marks it automatically as stale with a label.
        stale-pr-message: "This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. \n"
        # The message that will be added as a comment to the pull requests
        # when the stale workflow closes it automatically after being stale for too long.
        close-pr-message: "This pull request has been automatically closed because it has not had recent  activity.You can reopen the PR if you want. \n"
        stale-pr-label: lifecycle/stale
        # Exclude them from being marked as stale
        exempt-pr-labels: lifecycle/frozen,enhancement,good first issue
        # The issues or the pull requests with a milestone will not be marked as stale automatically
        exempt-all-milestones: true
        # Learn more about operations: https://github.com/actions/stale#operations-per-run.
        operations-per-run: 250
