Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2019 07:19
What would you like to do?
token = env("GH_TOKEN")
no_more_repos = false
page = 1
while !no_more_repos {
repos = `curl -s -H "Authorization: token $token" "$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" "$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" "$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