Skip to content

Instantly share code, notes, and snippets.

@odino
Created March 21, 2019 07:19
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 odino/d44b9d2caf9d90168aee7da2554e0dd7 to your computer and use it in GitHub Desktop.
Save odino/d44b9d2caf9d90168aee7da2554e0dd7 to your computer and use it in GitHub Desktop.
token = env("GH_TOKEN")
no_more_repos = false
page = 1
while !no_more_repos {
repos = `curl -s -H "Authorization: token $token" "https://api.github.com/orgs/namshi/repos?page=$page&type=private"`.json()
if !repos.len() {
no_more_repos = true
echo("End of repositories!")
return null
}
for r in repos {
repo_name = r.full_name
echo("Processing %s...", repo_name)
file = `curl -X GET -s -H "Authorization: token $token" "https://api.github.com/repos/$repo_name/contents/build.yml"`.json()
if file.sha {
sha = file.sha
delete = `curl -s -o /dev/null -w "%{http_code}" -X DELETE -H "Authorization: token $token" "https://api.github.com/repos/namshi/$repo_name/contents/build.yml" --data '{"message": "removed build.yml", "sha": "$sha"}'`
echo("%s %s", delete, repo_name)
} else {
echo("%s does not have a build.yml, skipping it", repo_name)
}
}
page += 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment