Skip to content

Make the Merge-Bot Task's delete-branch Input Delete Heads After an Auto-Merge #2296

Closed

Description

@ptr727

Problem

merge-bot-task.yml's delete-branch input appends --delete-branch to gh pr merge --auto. With --auto, the merge happens later on GitHub's side, once the required checks pass, and nothing deletes the head branch at that point. So for a repo that keeps repository-wide auto-delete off, the input has no effect, and the bot heads it exists to clean up stay behind.

Evidence

ptr727/homeassistant-purpleair keeps delete_branch_on_merge: false. Its carried merge-bot ran gh pr merge --auto --delete-branch --squash on the bot PR ptr727/homeassistant-purpleair#358. The PR auto-merged at 2026-10-03T02:08:30Z. Afterwards, git ls-remote origin refs/heads/ha-version-bump/matrix still returned df3a7e1, which is #358's merged headRefOid.

The hub task builds the same argument list (args=(--auto "$method"), then +=(--delete-branch)), so every adopter setting delete-branch: true inherits the gap.

Docs that describe the input as deleting bot heads:

  • docs/reusable-workflows.md, "Adopting the Merge-Bot"
  • the input's own description
  • the adopters' stub comments ("Bot heads are therefore deleted here explicitly")

Possible fixes

  • Delete the head after the merge actually lands, for example from a pull_request_target: closed job gated on merged == true, the bot author and the in-repo head, verifying the remote tip against the PR's headRefOid first.
  • Or drop the input and document that bot heads persist. A rolling branch like ha-version-bump/matrix is recreated by its tracker anyway, while Dependabot deletes its own branches.

🤖 Generated with Claude Code

Activity

  1. ptr727 commented on Oct 4, 2026

    @ptr727
    OwnerAuthor

    Maintainer decision (2026-10-03): keep the delete-branch input and make it work. Delete the head from a pull_request_target closed path gated on merged, the bot author and an in-repo head, and only when the remote tip still equals the PR's headRefOid. Repository-wide delete_branch_on_merge stays off fleet-wide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions