Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.sh Secret

Created March 25, 2023 02:01
Show Gist options
  • Select an option

  • Save KyMidd/f040473fbb1d912b8bf3ffeac6105656 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/f040473fbb1d912b8bf3ffeac6105656 to your computer and use it in GitHub Desktop.
# 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