Last active
February 24, 2023 08:49
-
-
Save knbknb/7397fa7497eddba1bb2ea8845f5958bf to your computer and use it in GitHub Desktop.
gitlab-gh: query all "awesome lists
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
#!/usr/bin/env bash | |
# using gh the commandline tool for github | |
# to filter for all repos with topic awesome-list | |
# and then get the json from gitlab | |
# needs gh, perl and jq installed | |
# gitlab-gh--awesome-lists.sh | |
# knb 2023 | |
DATE=$( date +%Y-%m-%d--%H-%M ) | |
OUTFILE=awesome-${DATE} | |
# fieldlist is a comma separated list of fields | |
# gotten from gitlab and to be re-sent to gitlab API | |
# createdAt,defaultBranch,description,forksCount,fullName,hasDownloads,hasIssues,hasPages,hasProjects,hasWiki,homepage,id,isArchived,isDisabled,isFork,isPrivate,language,license,name,openIssuesCount,owner,pushedAt,size,stargazersCount,updatedAt,url,visibility,watchersCount | |
#get fieldlist from gitlab, save to file | |
gh search repos --topic awesome awesome-list --json 2>&1 | grep -v Specify > fields.txt | |
# format fieldlist for gh | |
< fields.txt perl -lnE 'say qq($_,)' | xargs | perl -plE "s/ //g; s/,\$//;" > fields-oneliner.txt | |
fieldlist=$( cat fields-oneliner.txt ) | |
# get formatted json with list of from gitlab | |
gh search repos \ | |
--topic awesome awesome-list \ | |
--json $fieldlist \ | |
> $OUTFILE.json | |
< $OUTFILE.json jq ".[0]" | |
echo "< $OUTFILE.json jq \".[0]\"" | |
echo "output in $OUTFILE.json" | |
rm -i fields.txt fields-oneliner.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment