Clean up stale branches #9
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
| # Clean up orphaned/abandoned branches that have no open PR and no recent commits. | |
| # Related workflows: | |
| # - stale.yml: closes stale PRs/issues and deletes their branches (delete-branch: true) | |
| # - Repo setting "auto-delete head branches": removes branches after PR merge | |
| # This workflow covers the gap: branches pushed but never opened as a PR. | |
| name: Clean up stale branches | |
| on: | |
| schedule: | |
| - cron: "0 3 * * 0" # Weekly on Sundays at 3am UTC | |
| workflow_dispatch: | |
| inputs: | |
| dry-run: | |
| description: "Preview deletions without actually deleting" | |
| type: boolean | |
| default: true | |
| concurrency: | |
| group: branch-cleanup | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - name: Delete stale branches | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| STALE_DAYS: "30" | |
| run: >- # schedule trigger has no inputs — dry-run is false (live) by design | |
| ./hack/clean-stale-branches | |
| ${{ github.event.inputs.dry-run == 'true' && '--dry-run' || '' }} |