Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Last active March 25, 2023 01:33
Show Gist options
  • Select an option

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

Select an option

Save KyMidd/b668458a3c10d77b69a85cb4a0aff005 to your computer and use it in GitHub Desktop.
# This amazingly hacky way to get a repo count appears to be the only way, no official support in the APIs
# https://stackoverflow.com/a/33252219/12072110
REPO_BRANCH_COUNT=$(curl -vvvs \
-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=1" 2>&1 1>/dev/null \
| grep -E '< link: <https://' \
| rev \
| cut -d ">" -f 2 \
| cut -d "=" -f1 \
| rev)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment