Skip to content

Instantly share code, notes, and snippets.

@davidlj95
Last active September 6, 2023 22:26
Show Gist options
  • Save davidlj95/bbe8659c2239b7fdf950914c5ac2a41c to your computer and use it in GitHub Desktop.
Save davidlj95/bbe8659c2239b7fdf950914c5ac2a41c to your computer and use it in GitHub Desktop.
GitHub repositories with GitHub Pages enabled
#!/bin/sh
repos=$(gh repo list --limit 100 --json nameWithOwner | jq -r '.[].nameWithOwner')
count=0
echo "{"
for repo in $repos; do
has_pages="$(gh api repos/"$repo" --jq '.has_pages')"
echo " \"$repo\": $has_pages,"
if [ "$has_pages" = "true" ]; then
: $((count+=1))
fi
done
echo "}"
>&2 echo "Repos with pages enabled: $count"
@davidlj95
Copy link
Author

Lists all repositories in your GitHub account that have GitHub Pages enabled. In an almost JSON style. Almost: the last element will have a comma cause got lazy to see how to avoid that last one.

Requires GitHub CLI (gh) to be properly configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment