Geek-ubaid / gitcr

A dead simple script to create/delete repos in bulk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitCR

A dead simple script for bulk creation and deletion of GitHub repositories


Check out the blog related to this project: 7 things I learnt from a script for repository creation.

Functionalities

  • Bulk create repositories from a template
  • Revert creation

Instructions to run

Pre-requisites

Setup

You'll need 2 things to get started:

  1. A file called .env with the following variables. See the sample.

  2. 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

Execution

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


Output files

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

About

A dead simple script to create/delete repos in bulk

License:GNU General Public License v3.0


Languages

Language:Shell 93.0%Language:Python 4.7%Language:Dockerfile 2.3%