Skip to content

Instantly share code, notes, and snippets.

@rgs
Last active February 28, 2024 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgs/0d2c0c122b646c329f7cc32828d6f566 to your computer and use it in GitHub Desktop.
Save rgs/0d2c0c122b646c329f7cc32828d6f566 to your computer and use it in GitHub Desktop.
Find all repositories without CODEOWNERS
#!/bin/bash
# This will output a CSV of all non-archived repositories in the
# specified organisation, and whether the CODEOWNERS file is here
# or not found. Also exclude forked repositories. A suitable token
# must be in the environment variable $GH_TOKEN.
ORGA=rgs
for repo in $( gh repo list $ORGA --json isArchived,isFork,name --limit 500 \
--jq '.[] | select(.isArchived == false) | select(.isFork == false) | .name' \
| sort )
do
echo -n "$repo,"
gh api \
-H "Accept: application/vnd.github+json" \
-H "Authentication: Bearer $GH_TOKEN" \
/repos/$ORGA/$repo/contents/CODEOWNERS 2>/dev/null \
| jq -S '.name // .message'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment