Handle Stale PRs and Branches #200
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Handle Stale PRs and Branches | |
| on: | |
| schedule: | |
| - cron: '1 0 * * *' # every day at 00:01 | |
| jobs: | |
| prs: | |
| name: Clean up stale PRs | |
| runs-on: [self-hosted, Linux, X64] | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | |
| with: | |
| egress-policy: audit | |
| - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| operations-per-run: 200 | |
| stale-pr-message: "Hello! This PR has been open for 20 days without any activity. Therefore, it's considered as stale and is scheduled to be closed in 10 days. If you're still working on this, please remove the 'Stale' label or add a comment to keep it open. Thanks for your contribution!" | |
| days-before-pr-stale: 20 | |
| days-before-pr-close: 10 | |
| stale-pr-label: 'Stale' | |
| branches: | |
| name: Clean up stale branches | |
| runs-on: [self-hosted, Linux, X64] | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| - name: Run delete-old-branches-action | |
| uses: beatlabs/delete-old-branches-action@6e94df089372a619c01ae2c2f666bf474f890911 # v0.0.10 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| date: '2 months ago' | |
| dry_run: false | |
| delete_tags: false | |
| extra_protected_branch_regex: ^(master)$ | |
| exclude_open_pr_branches: true |