Skip to content

Instantly share code, notes, and snippets.

@kaar
Created January 31, 2021 19:07
Show Gist options
  • Save kaar/a02198f000f4eaade5d5aa8bf57ae069 to your computer and use it in GitHub Desktop.
Save kaar/a02198f000f4eaade5d5aa8bf57ae069 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
ACCESS_TOKEN=$(<access-token)
HEADER_ACCEPT="Accept: application/vnd.github.v3+json"
HEADER_AUTH="Authorization: token ${ACCESS_TOKEN}"
ORG=$1
url=https://api.github.com/orgs/$ORG/repos
pages=$(curl --silent -I -H "$HEADER_AUTH" -H "$HEADER_ACCEPT" "$url" | grep -Po "(?<=page=)[0-9]+" | tail -1)
for i in `seq 1 $pages`
do
curl --silent -H "$HEADER_AUTH" -H "$HEADER_ACCEPT" "${url}?page=${i}" \
| jq -r .[].name
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment