Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 15, 2025

  • Update "Clean up issues and pull requests" step in main branch's test.yml to delete PR branches
  • Test bash logic for correctness and edge cases
  • Code review completed and addressed
  • Address feedback:
    • Move branch extraction after gh pr close (closer to where it's used)
    • Move || true inside $() for proper error handling
    • Add TESTING_REPOSITORY environment variable to avoid hardcoding
    • Use environment variable in both the scan step and branch deletion
    • Use gh api instead of git push for consistent authentication context

The implementation:

  • Extracts branch name from each PR using gh pr view "$URL" --json headRefName -q .headRefName || true
  • Deletes the branch after closing the PR using gh api -X DELETE "repos/${{ env.TESTING_REPOSITORY }}/git/refs/heads/$branch"
  • Handles failures gracefully with || true inside command substitution
  • Uses centralized TESTING_REPOSITORY environment variable for consistency
  • Uses gh api for branch deletion to maintain consistent authentication context with other gh CLI commands

Note: Similar changes will need to be applied to v1 and v2 branches separately after this PR is merged.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Task] Delete copilot/* branches in E2E test workflow</issue_title>
<issue_description>### Problem

Before transferring the action to github/accessibility-scanner, I deleted thousands of copilot/* branches by running git branch -r | grep -Eo 'copilot/.*' | xargs -I {} git push origin :{}. This took more than 30 minutes to complete.

Because of https://github.com/github-community-projects/continuous-ai-for-accessibility-scanner/pull/2202 1, the new github/accessibility-scanner repo will never have thousands of defunct copilot/* branches…but github/accessibility-scanner-testing will. It’s already starting.

Solution

  • In main’s test.yml, v2’s test.yml, and v1’s test.yml update the “Clean up issues and pull requests” step to also delete the branch for each PR it deletes.
    • Do not use git branch -r | grep -Eo 'copilot/.*' | xargs -I {} git push origin :{} to delete all Copilot branches—that is too broad, and it could delete branches unrelated to E2E testing (i.e. branches we want to keep).
    • The gh CLI doesn’t have a command or flag for deleting branches alongside PRs, but something like this should work: branch="$(gh pr view <PR-number> --json headRefName -q .headRefName)" && [ -n "$branch" ] && git push origin --delete "$branch" || true.

Comments on the Issue (you are @copilot in this section)

Fixes github/continuous-ai-for-accessibility#76


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Footnotes

  1. And https://github.com/github/accessibility-scanner/pull/7/files#diff-faff1af3d8ff408964a57b2e475f69a6b7c7b71c9978cccc8f471798caac2c88 and https://github.com/github/accessibility-scanner/pull/8/files#diff-faff1af3d8ff408964a57b2e475f69a6b7c7b71c9978cccc8f471798caac2c88</issue_description>

Copilot AI changed the title [WIP] Delete copilot branches in E2E test workflow Delete copilot/* branches in E2E test workflow Oct 15, 2025
Copilot AI requested a review from smockle October 15, 2025 20:57
Copilot finished work on behalf of smockle October 15, 2025 20:57
Copilot AI requested a review from smockle October 15, 2025 21:11
Copilot finished work on behalf of smockle October 15, 2025 21:11
@smockle smockle marked this pull request as ready for review October 15, 2025 21:27
@smockle smockle requested a review from a team as a code owner October 15, 2025 21:27
@smockle smockle requested review from accessibility-bot and Copilot and removed request for accessibility-bot October 15, 2025 21:27
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 deletion of PR branches during E2E test cleanup to prevent accumulation of defunct copilot/* branches. The changes introduce branch deletion logic that extracts the branch name from each PR and removes it after closing the PR.

  • Adds TESTING_REPOSITORY environment variable for centralized repository configuration
  • Implements branch extraction and deletion logic in the cleanup workflow
  • Updates repository reference to use the new environment variable

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@smockle smockle marked this pull request as draft October 15, 2025 21:29
Copilot finished work on behalf of smockle October 15, 2025 21:33
Copilot AI requested a review from smockle October 15, 2025 21:33
Copilot finished work on behalf of smockle October 15, 2025 23:01
Copilot AI requested a review from smockle October 15, 2025 23:19
Copilot finished work on behalf of smockle October 15, 2025 23:19
@smockle smockle marked this pull request as ready for review October 17, 2025 17:21
@smockle smockle enabled auto-merge October 17, 2025 17:34
@smockle smockle merged commit fe49884 into main Oct 20, 2025
7 checks passed
@smockle smockle deleted the copilot/delete-copilot-branches-e2e branch October 20, 2025 17:47
smockle added a commit that referenced this pull request Oct 20, 2025
smockle added a commit that referenced this pull request Oct 20, 2025
smockle added a commit that referenced this pull request Oct 20, 2025
smockle added a commit that referenced this pull request Oct 20, 2025
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.

3 participants