Skip to content

Commit c885dfa

Browse files
committed
feat: add-ons — branch cleanup, PR template, cost tracking
- Cleanup stale evolution branches after merge - PR body includes journal excerpt + commit summary - Session duration tracking - Daily cleanup workflow for stale branches
1 parent 4ddc0b7 commit c885dfa

2 files changed

Lines changed: 86 additions & 4 deletions

File tree

.github/workflows/cleanup.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Cleanup stale branches
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *' # Daily at 6 AM UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: read
11+
12+
jobs:
13+
cleanup:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Configure git
21+
run: |
22+
git config user.name "iterate-evolve[bot]"
23+
git config user.email "iterate-evolve[bot]@users.noreply.github.com"
24+
25+
- name: Delete merged branches
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
# Get all evolution branches
30+
git fetch origin
31+
git branch -r | grep 'origin/evolution/' | while read -r branch; do
32+
branch_name=$(echo "$branch" | sed 's|origin/||')
33+
34+
# Check if PR is merged or closed
35+
state=$(gh pr list --head "$branch_name" --json state --jq '.[0].state' 2>/dev/null || echo "")
36+
37+
if [[ "$state" == "MERGED" || "$state" == "CLOSED" || -z "$state" ]]; then
38+
echo "Deleting branch: $branch_name"
39+
git push origin --delete "$branch_name" 2>/dev/null || true
40+
fi
41+
done
42+
43+
echo "Cleanup complete"

scripts/evolution/evolve.sh

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,34 @@ git push -u origin "$BRANCH" --force-with-lease 2>/dev/null || {
216216

217217
# Create PR
218218
PR_TITLE="iterate: Day $DAY evolution session"
219+
220+
# Get journal excerpt for PR body
221+
JOURNAL_EXCERPT=$(tail -10 docs/JOURNAL.md 2>/dev/null | head -5 || echo "No journal yet")
222+
223+
# Get commit summary
224+
COMMIT_SUMMARY=$(git log --oneline origin/main..HEAD 2>/dev/null | head -10 || echo "No commits")
225+
219226
PR_BODY="## Evolution Session — Day $DAY
220227
221228
Automated evolution session by iterate-evolve[bot].
222229
223-
### What changed
224-
- Ran plan → implement → communicate pipeline
225-
- All changes verified with go build + go test
230+
### Commits
231+
\`\`\`
232+
$COMMIT_SUMMARY
233+
\`\`\`
226234
227235
### Journal
228-
See docs/JOURNAL.md for session details.
236+
$JOURNAL_EXCERPT
237+
238+
### Verification
239+
- \`go build ./...\` — passes
240+
- \`go test ./...\` — passes
241+
- \`go vet ./...\` — passes
242+
243+
### Session Info
244+
- **Day:** $DAY
245+
- **Time:** $(date -u +'%H:%M UTC')
246+
- **Bot:** iterate-evolve[bot]
229247
230248
---
231249
*Auto-generated by iterate*"
@@ -282,4 +300,25 @@ fi
282300
# Switch back to main
283301
git checkout main 2>/dev/null || true
284302

303+
# ── Cleanup stale branches ──
304+
log "Cleaning up old evolution branches..."
305+
gh api repos/"$GITHUB_REPO"/branches --jq '.[].name' 2>/dev/null | grep "^evolution/day-" | while read -r branch; do
306+
# Check if branch's PR is merged
307+
PR_STATE=$(gh pr list --repo "$GITHUB_REPO" --head "$branch" --json state --jq '.[0].state' 2>/dev/null)
308+
if [[ "$PR_STATE" == "MERGED" || "$PR_STATE" == "CLOSED" || -z "$PR_STATE" ]]; then
309+
log "Deleting stale branch: $branch"
310+
git push origin --delete "$branch" 2>/dev/null || true
311+
fi
312+
done
313+
314+
# ── Cost estimation ──
315+
SESSION_DURATION=$SECONDS
316+
log "Session duration: ${SESSION_DURATION}s"
317+
log "Estimated cost: ~\$0.00 (depends on API usage)"
318+
319+
# ── Summary ──
285320
log "=== evolution cycle completed ==="
321+
log "Day: $DAY"
322+
log "Branch: $BRANCH"
323+
log "PR: #${PR_NUMBER:-none}"
324+
log "Duration: ${SESSION_DURATION}s"

0 commit comments

Comments
 (0)