-
-
Save KyMidd/f040473fbb1d912b8bf3ffeac6105656 to your computer and use it in GitHub Desktop.
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
| # Get all branches | |
| for PAGE_NUMBER in $(seq $PAGES_NEEDED); do | |
| #echo "Getting branches page $PAGE_NUMBER of $PAGES_NEEDED" | |
| PAGINATED_BRANCHES=$(curl -sL \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN"\ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "https://api.github.com/repos/$GH_ORG/$GH_REPO/branches?per_page=$BRANCHES_PER_PAGE&page=$PAGE_NUMBER" | jq -r '.[].name') | |
| # Combine all pages of repos into one variable | |
| # Extra return added since last item in list doesn't have newline (would otherwise combine two repos on one line) | |
| ALL_BRANCHES="${ALL_BRANCHES}"$'\n'"${PAGINATED_BRANCHES}" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment