Skip to content

Handle Stale PRs and Branches #1319

Handle Stale PRs and Branches

Handle Stale PRs and Branches #1319

Workflow file for this run

name: Handle Stale PRs and Branches
on:
schedule:
- cron: '1 0 * * *' # every day at 00:01
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
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@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.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'
ascending: true
branches:
name: Clean up stale branches
runs-on: [self-hosted, Linux, X64]
permissions:
contents: write
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
- name: Run branch cleanup script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x ./scripts/cleanup-old-branches.sh
./scripts/cleanup-old-branches.sh \
--months 2 \
--protected-branches "^(main|develop)$"