Skip to content

Instantly share code, notes, and snippets.

@officialmofabs
Forked from bashkirtsevich/upload.sh
Created February 14, 2023 21:56
Show Gist options
  • Save officialmofabs/6cdaeb918bea502196a224f42b06af1e to your computer and use it in GitHub Desktop.
Save officialmofabs/6cdaeb918bea502196a224f42b06af1e to your computer and use it in GitHub Desktop.
Automatic github uploader
#!/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