Skip to content

Instantly share code, notes, and snippets.

@whyvez
Created July 8, 2016 18:08
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 whyvez/6e090e3db9e4fca4e3ff84eeed9c2897 to your computer and use it in GitHub Desktop.
Save whyvez/6e090e3db9e4fca4e3ff84eeed9c2897 to your computer and use it in GitHub Desktop.
Shell script that prints out repos in a CSV format as a task list for repo cleanup.
#!/usr/bin/env bash
# prints a list of github org repos as csv with additional fields to track cleanup tasks.
# usage: bash ./repo-cleanup.sh <org> <your-gh-pat>
# gh api docs:
# auth: https://developer.github.com/v3/#authentication
# repos: https://developer.github.com/v3/repos/
# pagination: https://developer.github.com/v3/#pagination
org=$1
access_token=$2
curl "https://api.github.com/orgs/$org/repos?access_token=$access_token&page=1&per_page=100" \
| jq '.[].name' \
| LC_COLLATE=C sort --ignore-case \
| awk -F, -v org=$org '
BEGIN {
print "repo" FS "owner" FS "readme" FS "license" FS "tests" FS "ci" FS "publish" FS "reviewed_by"
}
{
gsub("\"", "");
print $1 FS org FS "no" FS "no" FS "no" FS "no" FS "no" FS "na"
} '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment