Skip to content

26T1-OPS-DHR-008 Branch cleanup feature#223

Open
6igby wants to merge 3 commits into
mainfrom
feature/branch-cleanup
Open

26T1-OPS-DHR-008 Branch cleanup feature#223
6igby wants to merge 3 commits into
mainfrom
feature/branch-cleanup

Conversation

@6igby
Copy link
Copy Markdown
Collaborator

@6igby 6igby commented May 8, 2026

Note: this should only be merged after chore/ci-cleanup-v2 has been merged into main, as it builds off that branch

Summary

This feature includes a singular workflow file to automatically delete a branch after it has specifically been merged to main. This was called out by Ryan in the DevSecOps group chat, and he is completely right. We currently have around 70+ branches and if the reviewer doesn't delete a branch after merging it to main, it can become a repetitive process to manually delete redundant branches.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / code cleanup
  • Documentation
  • CI/CD / infrastructure
  • Security

Affected Components

  • /backend-api
  • /frontend
  • /engine (collectors / policies)
  • /security
  • /infrastructure
  • /.github/workflows
  • /docs

Motivation

To reduce manual deletion of no longer used/needed branches.
Planner ID: 26T1-OPS-DHR-008: Branch Cleanup Workflow

Testing Done

  • Unit tests pass locally
  • Tested manually — describe how:
  • No tests required — explain why:
    Tested this in my own repo to ensure that the workflow fires as it should, video demo below:
2026-05-08.15-34-01.mp4

Security Considerations

No security impact, however, logic for such a feature may have the chance to delete a branch that should not yet be deleted (e.g. if a PR is open and it has been closed for further implementation, but not merged. If a branch that has been accidentally pushed into another branch over main). However, this workflow only fires after on the condition that the PR has been merged, whilst it only targets main.
on: pull_request: types: [closed] branches: [main]

github.event.pull_request.merged == true && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.head.ref != 'main'

Breaking Changes

  • No breaking changes
  • Yes — describe below:

Rollback Plan

  • Revert commit is sufficient
  • Requires additional steps — describe below:

Checklist

  • Code follows project conventions
  • No secrets, credentials, or tokens committed
  • Relevant documentation updated (if applicable)
  • CI/CD workflows pass on this branch
  • PR is focused on one thing

Screenshots

N/A

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00607b7b9d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if: |
github.event.pull_request.merged == true &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.head.ref != 'main'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exempt long-lived branches from auto-delete

This condition only protects main, so any same-repo PR merged into main from a persistent branch (for example engine-development) will be deleted automatically. That is risky here because operational workflows still depend on long-lived branches (e.g., .github/workflows/ops.collector.yml and .github/workflows/ci.opa-eval.yml both trigger on engine-development), so one merge can silently remove a branch those automations require.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

@liyunze-coding liyunze-coding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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