Forked from sandipndev/all-repos-using-access-token.sh
Created
October 9, 2021 13:27
-
-
Save spantheslayer/831f171db1d5a11b8e4ade1605862e31 to your computer and use it in GitHub Desktop.
Leaving an Organization? Here's your safety pin! All you have to do is get an Access Token!
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
#!/bin/bash | |
# Organization Name | |
echo -n "Enter Organization Slug: " | |
read ORG | |
# Access Token | |
echo -n "Enter GitHub Access Token: " | |
read GH_ACCESS_TOKEN | |
# Downloading and parsing the list of ssh clone urls | |
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${GH_ACCESS_TOKEN}" https://api.github.com/orgs/${ORG}/repos?per_page=100 | jq --raw-output -c '.[].full_name?' > repos | |
# Download each repo | |
while IFS= read -r repo; do | |
git clone https://$GH_ACCESS_TOKEN:x-oauth-basic@github.com/$repo | |
done < repos | |
# Cleanup | |
rm repos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment