Skip to content

Instantly share code, notes, and snippets.

@siketyan
Created March 9, 2023 05:16
Show Gist options
  • Save siketyan/7832f8ff5130d263b1fa3361d68a6a6b to your computer and use it in GitHub Desktop.
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.
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