Created
October 11, 2021 19:28
-
-
Save bashkirtsevich/8d69a4ced76831562ac7b04fef043552 to your computer and use it in GitHub Desktop.
Automatic github uploader
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 | |
TOKEN="..." | |
ORG="..." | |
for repo in */ ; do | |
repo_name=$(echo $repo | sed 's/\///') | |
echo "Found folder $repo_name" | |
cp LICENSE $repo_name/LICENSE | |
echo "Create new repository $repo_name" | |
gh_response=$(curl -X POST https://api.github.com/orgs/$ORG/repos -H "authorization: token $TOKEN" -d "{\"name\": \"$repo_name\"}") | |
echo "GitHub response:\n$gh_response" | |
repo_url=$(echo $gh_response | jq -r ".ssh_url") | |
echo "Url for repo $repo_name is: $repo_url" | |
echo "Change directory to $repo_name" | |
pushd $repo_name | |
git init -b master | |
git add --all | |
git commit -a -m 'Initial commit' | |
git remote add origin $repo_url | |
git push origin master | |
echo "Push files to $repo_url" | |
popd | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment