Skip to content

Instantly share code, notes, and snippets.

@L04DB4L4NC3R
Last active January 15, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L04DB4L4NC3R/3e366e1ac93c3d3036d107c2386b1e46 to your computer and use it in GitHub Desktop.
Save L04DB4L4NC3R/3e366e1ac93c3d3036d107c2386b1e46 to your computer and use it in GitHub Desktop.
GitHub repo creation script (from template)
GITHUB_PERSONAL_ACCESS_TOKEN=
GITHUB_TEMPLATE_NAME=
GITHUB_TEMPLATE_OWNER=
GITHUB_ORGANIZATION_OWNER=
#!/bin/bash
source ./.env
template_name=$GITHUB_TEMPLATE_NAME
template_owner=$GITHUB_TEMPLATE_OWNER
owner_name=$GITHUB_ORGANIZATION_OWNER
token=$GITHUB_PERSONAL_ACCESS_TOKEN
echo "Running..."
while p= read -r line; do
echo "Creating $line"
curl -XPOST -d "{\"owner\": \"$owner_name\", \"name\": \"$line\"}" https://api.github.com/repos/$template_owner/$template_name/generate -H "Accept: application/vnd.github.baptiste-preview+json" -H "Authorization: token $token" &>/dev/null
echo "Sleeping for 1.5s"
sleep 1.5 # For avoiding rate limit of 10 req per min
done < ./repos.txt
test1
test2
test3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment