Skip to content

Commit

Permalink
make delete like fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Oct 28, 2024
1 parent 9e6ddf2 commit 5a0ac33
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/release_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down

0 comments on commit 5a0ac33

Please sign in to comment.