Created
March 9, 2023 05:16
-
-
Save siketyan/7832f8ff5130d263b1fa3361d68a6a6b to your computer and use it in GitHub Desktop.
Looks up whether the default branch is protected or not for each repositories on GitHub.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set owner "siketyan" | |
for r in (gh repo list $owner --limit 1000 --json owner,name,defaultBranchRef | jq -rc '.[]') | |
set owner (echo $r | jq -r '.owner.login') | |
set repo (echo $r | jq -r '.name') | |
set branch (echo $r | jq -r '.defaultBranchRef.name') | |
if gh api repos/$owner/$repo/branches/$branch/protection > /dev/null 2>&1 | |
echo "$owner/$repo OK" | |
else | |
echo "$owner/$repo NG" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment