26T1-OPS-DHR-008 Branch cleanup feature#223
Conversation
There was a problem hiding this comment.
💡 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' |
There was a problem hiding this comment.
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 👍 / 👎.
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
Affected Components
/backend-api/frontend/engine(collectors / policies)/security/infrastructure/.github/workflows/docsMotivation
To reduce manual deletion of no longer used/needed branches.
Planner ID: 26T1-OPS-DHR-008: Branch Cleanup Workflow
Testing Done
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
Rollback Plan
Checklist
Screenshots
N/A