Add branch-cleanup mise task (#247)
## Summary - New `mise run branch-cleanup` task that finds branches merged into main and deletes them locally and on the Forgejo remote - Configurable `--cutoff` (default 30 days) skips branches with recent HEAD commits - Supports `--dry-run`, `--local-only`, `--remote-only` flags - Interactive confirmation before any deletion ## Test plan - [x] `mise run branch-cleanup -- --dry-run` shows correct table of candidates - [ ] Run without `--dry-run` to confirm actual deletion works Reviewed-on: https://forge.ops.eblu.me/eblume/blumeops/pulls/247
This commit is contained in:
parent
d51c180fe6
commit
abb7e6fe88
3 changed files with 470 additions and 0 deletions
40
.forgejo/workflows/branch-cleanup.yaml
Normal file
40
.forgejo/workflows/branch-cleanup.yaml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# Automated Branch Cleanup
|
||||
#
|
||||
# Deletes remote branches that have been merged into main and are older
|
||||
# than a cutoff (default 30 days). Detects both fast-forward and
|
||||
# squash-merged branches via the Forgejo API.
|
||||
#
|
||||
# Runs on a schedule (~every 10 days) and can be triggered manually
|
||||
# with a custom cutoff for testing.
|
||||
|
||||
name: Branch Cleanup
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Approximately every 10 days: 1st, 11th, 21st of each month at 06:00 UTC
|
||||
- cron: '0 6 1,11,21 * *'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
cutoff:
|
||||
description: 'Delete branches older than N days'
|
||||
required: false
|
||||
default: '30'
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
runs-on: k8s
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run branch cleanup
|
||||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
CUTOFF="${{ inputs.cutoff || '30' }}"
|
||||
echo "Running branch cleanup with cutoff=${CUTOFF} days..."
|
||||
uv run --script mise-tasks/branch-cleanup \
|
||||
--remote-only \
|
||||
--yes \
|
||||
--cutoff "$CUTOFF"
|
||||
Loading…
Add table
Add a link
Reference in a new issue