[chore]: add delete-outdated-pr-branches GitHub Action#1108
[chore]: add delete-outdated-pr-branches GitHub Action#1108kevalmorabia97 merged 1 commit intomainfrom
Conversation
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
📝 WalkthroughWalkthroughA new GitHub Actions workflow is introduced that automatically deletes remote branches corresponding to closed or merged pull requests. The workflow runs weekly on Mondays and can be triggered manually, iterating through pull-request branches and removing those no longer active. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/delete_outdated_pr_branches.yml (1)
32-32: Consider preserving stderr for debugging.Suppressing stderr with
2>/dev/nullmay hide useful error messages when troubleshooting. Consider logging to a variable or removing the suppression since the|| echo ""fallback already handles failures gracefully.♻️ Optional: Capture stderr for visibility
- STATE=$(gh pr view "$branch" --repo "$REPO" --json state --jq '.state' 2>/dev/null || echo "") + STATE=$(gh pr view "$branch" --repo "$REPO" --json state --jq '.state' || echo "")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/delete_outdated_pr_branches.yml at line 32, The command that sets STATE uses stderr suppression (2>/dev/null) which hides gh CLI errors; remove the redirection or capture stderr for debugging so failures are visible—for example, change the assignment that uses STATE=$(gh pr view "$branch" --repo "$REPO" --json state --jq '.state' 2>/dev/null || echo "") to either remove "2>/dev/null" so gh errors appear, or capture stderr into a separate variable (e.g., ERR) via "2>&1" and log ERR when STATE is empty; update references to STATE, the gh pr view invocation, "$branch" and "$REPO" accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/delete_outdated_pr_branches.yml:
- Line 32: The command that sets STATE uses stderr suppression (2>/dev/null)
which hides gh CLI errors; remove the redirection or capture stderr for
debugging so failures are visible—for example, change the assignment that uses
STATE=$(gh pr view "$branch" --repo "$REPO" --json state --jq '.state'
2>/dev/null || echo "") to either remove "2>/dev/null" so gh errors appear, or
capture stderr into a separate variable (e.g., ERR) via "2>&1" and log ERR when
STATE is empty; update references to STATE, the gh pr view invocation, "$branch"
and "$REPO" accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a4b01f70-d2ac-4481-b540-943c272e8469
📒 Files selected for processing (1)
.github/workflows/delete_outdated_pr_branches.yml
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1108 +/- ##
=======================================
Coverage 70.23% 70.23%
=======================================
Files 227 227
Lines 25909 25909
=======================================
Hits 18198 18198
Misses 7711 7711 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What does this PR do?
Type of change: new feature
Adds a scheduled GitHub Action that automatically deletes
pull-request/<num>branches where the corresponding PR is no longer open (i.e., closed or merged). This prevents stale branches from accumulating over time.Testing
The workflow can be triggered on-demand via
workflow_dispatchfor manual testing before relying on the weekly schedule.Before your PR is "Ready for review"
CONTRIBUTING.md: N/ASummary by CodeRabbit