Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false # Allow previous workflows’ clean-up steps to complete

env:
TESTING_REPOSITORY: github/accessibility-scanner-testing

jobs:
test:
name: Test
Expand Down Expand Up @@ -74,7 +77,7 @@ jobs:
login_url: http://127.0.0.1:4000/
username: ${{ secrets.TEST_USERNAME }}
password: ${{ secrets.TEST_PASSWORD }}
repository: github/accessibility-scanner-testing
repository: ${{ env.TESTING_REPOSITORY }}
token: ${{ secrets.GH_TOKEN }}
cache_key: ${{ steps.cache_key.outputs.cache_key }}

Expand Down Expand Up @@ -110,6 +113,11 @@ jobs:
if [[ "$URL" == *"/pull/"* ]]; then
echo "Closing pull request: $URL"
gh pr close "$URL" || echo "Failed to close pull request: $URL"
branch="$(gh pr view "$URL" --json headRefName -q .headRefName || true)"
if [[ -n "$branch" ]]; then
echo "Deleting branch: $branch"
gh api -X DELETE "repos/${{ env.TESTING_REPOSITORY }}/git/refs/heads/$branch" || echo "Failed to delete branch: $branch"
Comment on lines +118 to +119
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

The branch deletion logic could potentially delete protected or important branches if the PR URL parsing fails or returns unexpected branch names. Consider adding validation to ensure only test-related branches are deleted, such as checking for a specific prefix pattern.

Suggested change
echo "Deleting branch: $branch"
gh api -X DELETE "repos/${{ env.TESTING_REPOSITORY }}/git/refs/heads/$branch" || echo "Failed to delete branch: $branch"
if [[ "$branch" == test-* || "$branch" == ci-* ]]; then
echo "Deleting branch: $branch"
gh api -X DELETE "repos/${{ env.TESTING_REPOSITORY }}/git/refs/heads/$branch" || echo "Failed to delete branch: $branch"
else
echo "Skipping deletion of non-test branch: $branch"
fi

Copilot uses AI. Check for mistakes.
fi
elif [[ "$URL" == *"/issues/"* ]]; then
echo "Closing issue: $URL"
gh issue close "$URL" || echo "Failed to close issue: $URL"
Expand Down