Last active
January 15, 2022 23:26
-
-
Save davidmerrick/c189d31a4f3d186f187846c1f6656964 to your computer and use it in GitHub Desktop.
Clone all github repos in an org
This file contains hidden or 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
#!/bin/bash | |
# Note: This script requires that you have $GITHUB_TOKEN set. | |
# Get one here: https://github.com/settings/tokens | |
ORG=yourOrg | |
HAS_NEXT=true | |
i=1 | |
while $HAS_NEXT | |
do | |
REPOS=$(curl "https://api.github.com/orgs/$ORG/repos?per_page=100&page=$i" \ | |
-H "Accept: application/vnd.github.machine-man-preview+json" \ | |
-H "Authorization: Bearer $GITHUB_TOKEN" | jq .[].ssh_url) | |
if [[ $(echo $REPOS | wc -w) -eq 0 ]] | |
then | |
HAS_NEXT=false | |
fi | |
echo $REPOS | xargs -n 1 git clone | |
i=$(expr $i + 1) | |
done |
Hey sorry @jitunair18, I'm just now seeing this. I would assume the visibility of the repo would be based on the scopes of your token. Is that not the behavior that you're seeing?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to make this work for private repositories?