Skip to content

Conversation

@thedannywahl
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings October 18, 2025 16:50
@thedannywahl thedannywahl enabled auto-merge (squash) October 18, 2025 16:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds automatic cleanup of release branches after they are merged. The workflow now includes a step to delete the release branch once the auto-merge is confirmed complete.

Key Changes

  • Added a new workflow step that executes after PR auto-merge is enabled
  • Implements branch deletion with safety checks to verify the PR was actually merged

Comment on lines +118 to +127
# Wait for PR to be merged
pr_number="$(gh pr view "$BRANCH" --json number -q .number)"
# Confirm PR is merged before deleting branch
merged="$(gh pr view "$pr_number" --json merged -q .merged)"
if [ "$merged" = "true" ]; then
git push origin --delete "$BRANCH"
echo "Deleted branch $BRANCH after successful merge."
else
echo "PR not merged, branch not deleted."
fi
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

The comment on line 118 is misleading - the code doesn't actually wait for the PR to be merged. Since auto-merge was just enabled in the previous step (line 110), the PR may not be merged yet when this step runs. This could result in the branch not being deleted even though the PR will eventually merge. Consider adding a polling loop with timeout to actually wait for the merge, or use GitHub's branch protection settings to automatically delete branches after merge instead.

Suggested change
# Wait for PR to be merged
pr_number="$(gh pr view "$BRANCH" --json number -q .number)"
# Confirm PR is merged before deleting branch
merged="$(gh pr view "$pr_number" --json merged -q .merged)"
if [ "$merged" = "true" ]; then
git push origin --delete "$BRANCH"
echo "Deleted branch $BRANCH after successful merge."
else
echo "PR not merged, branch not deleted."
fi
# Poll for PR to be merged (max 5 minutes, check every 10 seconds)
pr_number="$(gh pr view "$BRANCH" --json number -q .number)"
timeout=300
interval=10
elapsed=0
while true; do
merged="$(gh pr view "$pr_number" --json merged -q .merged)"
if [ "$merged" = "true" ]; then
git push origin --delete "$BRANCH"
echo "Deleted branch $BRANCH after successful merge."
break
fi
if [ "$elapsed" -ge "$timeout" ]; then
echo "Timeout waiting for PR to be merged. Branch not deleted."
break
fi
echo "PR not merged yet, waiting..."
sleep "$interval"
elapsed=$((elapsed + interval))
done

Copilot uses AI. Check for mistakes.
run: |
set -euo pipefail
# Wait for PR to be merged
pr_number="$(gh pr view "$BRANCH" --json number -q .number)"
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

The PR number is already retrieved in the previous step and could be passed to this step to avoid redundant API calls. Consider storing the PR number in an output variable in the 'Create pull request' step and referencing it here using steps.create_pr.outputs.pr_number instead of making another API call.

Copilot uses AI. Check for mistakes.
@thedannywahl thedannywahl merged commit 1f9bfec into main Oct 18, 2025
4 checks passed
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