Nightly Branch Cleanup #146
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |