From 5a0ac332fa1af9cc5a138cae33374b7d62ded0f5 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 28 Oct 2024 09:04:22 -0600 Subject: [PATCH] make delete like fetch --- .github/workflows/release_parallel.yml | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 100a9fe1ce..adfc9fe754 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -252,30 +252,30 @@ jobs: - name: Delete branches run: | - echo "Starting branch deletion process..." - echo "Raw branches input:" - echo "${{ steps.collect-branches.outputs.branches }}" - - # Convert newline-separated string to array - IFS=$'\n' read -r -d '' -a BRANCHES_TO_DELETE <<< "${{ steps.collect-branches.outputs.branches }}" - - echo "Number of branches to delete: ${#BRANCHES_TO_DELETE[@]}" - echo "All branches to delete:" - printf '%s\n' "${BRANCHES_TO_DELETE[@]}" - - # Delete branches in batches of 100 - BATCH_SIZE=100 - for ((i = 0; i < ${#BRANCHES_TO_DELETE[@]}; i += BATCH_SIZE)); do - BATCH=("${BRANCHES_TO_DELETE[@]:i:BATCH_SIZE}") - echo "Processing batch starting at index $i" - echo "Batch size: ${#BATCH[@]}" - echo "Batch contents:" - printf '%s\n' "${BATCH[@]}" - echo "Deleting batch of branches: ${BATCH[*]}" - git push origin --delete ${BATCH[@]} || echo "Failed to delete some branches in batch, continuing..." + echo "Fetching all branches..." + # Check if we have any branches to fetch + if [ -z "${{ steps.collect-branches.outputs.branches }}" ]; then + echo "No branches to fetch" + exit 0 + fi + + # Convert to array, filtering out empty lines and trimming whitespace + readarray -t BRANCH_ARRAY < <(echo "${{ steps.collect-branches.outputs.branches }}" | grep .) + + if [ ${#BRANCH_ARRAY[@]} -eq 0 ]; then + echo "No valid branches found" + exit 0 + fi + + echo "Found ${#BRANCH_ARRAY[@]} branches to fetch" + # Build fetch refs with proper formatting + BRANCHES_TO_DELETE="" + for branch in "${BRANCH_ARRAY[@]}"; do + BRANCHES_TO_DELETE+=" ${branch}" done - echo "Branch deletion process complete" + echo "BRANCHES_TO_DELETE: $BRANCHES_TO_DELETE" + git push origin --delete ${BRANCHES_TO_DELETE} - name: Create release run: |