Check out the blog related to this project: 7 things I learnt from a script for repository creation.
- Bulk create repositories from a template
- Revert creation
- Docker, or a linux based system with curl and jq installed.
- Github personal access token with write and delete permissions.
- A template repository.
You'll need 2 things to get started:
-
A file called
.env
with the following variables. See the sample. -
The second thing that is needed is a
repos.txt
file with the name of the repositories that you want to create. The number of repositories can be anywhere between 1 to 5000, due to the rate limitation of the GitHub API. eg:
repo-1
repo-2
repo-3
...
repo-5000
See a sample here
To run the scripts on any platform, replace {PATH}
with the absolute file path of where your script exists, then run the command(s) below:
# For creation
docker run --rm --mount type=bind,source="{PATH}",target=/usr/app/cli/ angadsharma1016/gitcr -c "bash /usr/app/cli/gitcr create"
# For deletion/reverting creation
docker run --rm --mount type=bind,source="{PATH}",target=/usr/app/cli/ angadsharma1016/gitcr -c "bash /usr/app/cli/gitcr revert"
# For creation and piping JSON output to a file
docker run --rm --mount type=bind,source="{PATH}",target=/usr/app/cli/ angadsharma1016/gitcr -c "bash /usr/app/cli/gitcr create --out=json"
# For deletion/reverting and piping JSON output to a file
docker run --rm --mount type=bind,source="{PATH}",target=/usr/app/cli/ angadsharma1016/gitcr -c "bash /usr/app/cli/gitcr revert --out=json"
To run the scripts natively (in linux based systems):
# One time execution needed for the 2 commands below
$ chmod +x gitcr
$ ./gitcr
# Once done, the following commands can be executed:
# To create bulk repositories
$ ./gitcr create
# To create bulk repositories and pipe output JSON to a file
$ ./gitcr create --out=json
# To revert/delete the created repositories
$ ./gitcr revert
# To revert/delete the created repositories and pipe output JSON to a file
$ ./gitcr revert --out=json
If you have used a --out=json
flag then a file will be created in the output/ directory. See the samples for creation and deletion , or see one below:
[
{
"repo_name": "generated-01",
"status": "SUCCESS",
"order_of_execution": 0,
"code": 201,
"url": "https://github.com/L04DB4L4NC3R/generated-01"
},
{
"repo_name": "generated-02",
"status": "SUCCESS",
"order_of_execution": 1,
"code": 201,
"url": "https://github.com/L04DB4L4NC3R/generated-02"
}
]
And for deletion:
[
{
"repo_name": "generated-01",
"status": "FAILURE",
"order_of_execution": 0,
"code": 404
},
{
"repo_name": "generated-02",
"status": "FAILURE",
"order_of_execution": 1,
"code": 404
}
]
Made with ❤️ by L04DB4L4NC3R