Created
March 21, 2019 07:19
-
-
Save odino/d44b9d2caf9d90168aee7da2554e0dd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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