Skip to content

Add daily cleanup for stale copilot/ branches - #47199

Closed
pelikhan with Copilot wants to merge 2 commits into
mainfrom
copilot/delete-inactive-copilot-branches
Closed

Add daily cleanup for stale copilot/ branches#47199
pelikhan with Copilot wants to merge 2 commits into
mainfrom
copilot/delete-inactive-copilot-branches

Conversation

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Adds a scheduled workflow to prune copilot/ branches that have gone inactive for more than 24 hours. This keeps short-lived agent branches from accumulating while preserving recently active work.

  • Workflow

    • Adds .github/workflows/daily-copilot-branch-cleaner.md with a daily schedule and manual trigger.
    • Compiles the workflow to .github/workflows/daily-copilot-branch-cleaner.lock.yml.
  • Branch cleanup behavior

    • Enumerates refs under refs/heads/copilot/.
    • Reads the head commit timestamp for each branch and treats the most recent author/committer time as last activity.
    • Deletes only branches whose last activity is at least 24 hours old.
  • Operational visibility

    • Emits a step summary with per-branch outcomes: deleted, kept, skipped, or failed.
    • Fails the run if any deletion attempt errors so cleanup problems surface instead of being silently ignored.
on:
  schedule:
    - cron: "17 3 * * *"
  workflow_dispatch:

jobs:
  cleanup_copilot_branches:
    permissions:
      contents: write
if (ageHours < 24) {
  results.push({ branch, action: 'kept' });
} else {
  await github.rest.git.deleteRef({ owner, repo, ref: `heads/${branch}` });
}

Copilot AI and others added 2 commits July 21, 2026 12:17
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan closed this Jul 22, 2026
@github-actions
github-actions Bot deleted the copilot/delete-inactive-copilot-branches branch July 29, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants