Skip to content

Nightly Branch Cleanup #146

Nightly Branch Cleanup

Nightly Branch Cleanup #146

name: 'Nightly Branch Cleanup'
on:
schedule:
- cron: '0 5 * * *'
jobs:
cleanup-branches:
if: github.repository == 'tenstorrent/tt-zephyr-platforms'
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Fetch all branches
fetch-depth: 0
- name: Clean Branches
run: |
ALL_BRANCHES=$(git branch -r | grep -v 'HEAD' | awk '{print $1}' | sed 's|origin/||')
for branch in $ALL_BRANCHES; do
echo -n "Found branch $branch..."
if [[ "$branch" == "main" || "$branch" =~ ^v.*-branch$ || "$branch" =~ ^collab.* ]]; then
echo -e " \033[32mSkipping\033[0m"
continue
fi
echo -e " \033[31mDeleting\033[0m"
git push origin --delete "$branch"
done
echo "Done"