Skip to content

IAmHughes/IAmRepoCleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 

Repository files navigation

IAmRepoCleaner

This script, repo-cleaner, will delete every repository matching a specific pattern for either a user or organization based on options passed through the command line. This solves the problem many of us experience when doing testing where multiple repositories are created and need to be deleted after the testing/debugging is finished.

PRE-REQUISITES

AUTHENTICATION:

Before running this script, you must create a Personal Access Token (PAT) (see: creating a personal access token for more info) with the permissions <repo> and <delete_repo> scopes. You can read more about Scopes for OAuth Apps here. Once created, you must export your PAT as an environment variable named <GITHUB_TOKEN>.

  • Exporting PAT as GITHUB_TOKEN
export GITHUB_TOKEN=abcd1234efg567

RUNNING THE SCRIPT

NAME:

repo-cleaner - Deletes every repository matching a specific name pattern for the user or org specified up to 30 at a time

SYNOPSIS:

repo-cleaner [-o=<org_name>] [-u=<username>] [-s=<string-to-match-against>]

DESCRIPTION:

Deletes every repository for the user (if -u=<username> is used) or for an organization (if -o=<org_name> is used instead) that matches the string (specified by -s=<string-to-match-against>). If -s is omitted it will list the repos available to delete instead. Will delete up to 30 repositories with every execution due to default pagination.

OPTIONS:

--org | -o

When running the tool, this flag sets the API endpoint to point to an organization (specififed by -o=<org_name>), deleting the repos that match the given string from -s (see below).

  • NOTE: Can NOT be used with the -u option.

--user | -u

When running the tool, this flag sets the API endpoint to point to a user (specified by -u=<username>), deleting the repos that match the given string from -s (see below).

  • NOTE: Can NOT be used with the -o option.

--string | -s

When running the tool, this flag sets the string to match against the name of the repo(s) you are wanting to delete. If omitted will list repositories for given user or organization (specified by -u=<username> or -o=<org_name>) without deleting any.

EXAMPLES:

  • Lists repos under user account IAmHughes that are available to be deleted.
bash repo-cleaner -u=IAmHughes
  • Deletes repos under org TheBeardedTom that are named Test_Repo_
    • For example: Test_Repo_, Test_Repo_qa, Test_Repo_234, etc. would be deleted.
bash repo-cleaner -o=TheBeardedTom -s=Test_Repo_
  • Deletes repos under user IAmHughes that are named MyRepo
    • For example: MyRepo, MyRepo1, MyRepo99, MyRepoQA, etc. would all be deleted.
bash repo-cleaner -u=IAmHughes -s=MyRepo

API DOCUMENTATION:

All documentation can be found at the GitHub Developer Docs page.

CONTRIBUTING

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

AUTHORS

  • Thomas Hughes - Maintainer / On-Going Support - @IAmHughes
  • Michael Johnson - Initial Work - @Migarjo

See also the list of contributors who participated in this project.

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details.

ACKNOWLEDGEMENTS

  • Thanks to @Migarjo for the initial base for the script.

About

Deletes repositories for a user or organization that match a specific pattern.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages