I am setting up a central documentation repo using Github Pages.
I have a bash script that runs before deploying the pages that: dynamically looks at specific repos in a list that the doc repo has access to, takes their description, and puts the contents of the description underneath the repo's title name.
What I want to do is extend this script to look up a repo in the list, take all the contents of various README.md's that are in the repo, or CHANGELOG.md file, and concatenate them into one page that can be deployed. What is the most efficient way to find and grab the list of files and their contents using the Github API? I have looked through the documentation but only found the ability to checkout the entire repository, and this can get expensive with a large number of repos in the list.
Yes, you can actually do this using gh
. For instance, to grab the README.md file for terraform:
repo="hashicorp/terraform"
gh api "/repos/${repo}/contents/README.md" | jq -r '.content' | base64 -d