Last active
March 16, 2022 02:49
-
-
Save exoego/1b1380dca387acaf17b26ac166077c9a to your computer and use it in GitHub Desktop.
Fetch .ruby-version in company repo
This file contains hidden or 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
#!/bin/zsh | |
OWNER=my-company | |
gh search repos \ | |
--owner=$OWNER \ | |
--language=ruby \ | |
--visibility=private \ | |
--archived=false \ | |
--json="name,defaultBranch" \ | |
--limit=200 \ | |
> repos.json | |
result="repo, last_updated_at, .ruby_version\n" | |
for line in `cat repos.json | jq '.[] | .name + "@" + .defaultBranch' --raw-output`; do | |
parts=(${(@s/@/)line}) | |
repo=$parts[1] | |
defaultBranch=$parts[2] | |
lastUpdatedAt=$(gh api repos/$OWNER/$repo/commits/$defaultBranch | jq '.commit.author.date' --raw-output) | |
ruby_version=$(gh api repos/$OWNER/$repo/contents/.ruby-version --header="Accept: application/vnd.github.VERSION.raw") | |
if [[ $ruby_version == *"Found"* ]]; then | |
result+="$repo, $lastUpdatedAt, not found\n" | |
else | |
result+="$repo, $lastUpdatedAt, $ruby_version\n" | |
fi | |
done | |
echo $result > result.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment