GitHub API: User Repositories JSON
A call to the GitHub API. The response is output to a repos.json file
curl https://api.github.com/users/whaleen/repos -o repos.json;
Test the output received at: https://api.github.com/users/whaleen/repos
Jekyll Use Case #
In a Jekyll site I have hosted on netlify, this in my netlify.toml
file:
[build]
command = 'curl https://api.github.com/users/whaleen/repos -o _data/repos.json; jekyll build'
Netlify will run that build command whenever a deploy is triggered. Netlify respects your netlify.toml file.
11ty Use Case #
Same as with Jekyll I will put the repos.json into a _data file.
Add script to package.json:
"scripts": {
"build": "eleventy",
"watch": "eleventy --watch",
"serve": "eleventy --serve",
"debug": "DEBUG=* eleventy",
"comment": "Script below, gh-repos, gets repos and puts in _data dir for consumption by 11ty or Jekyll",
"gh-repos": "curl https://api.github.com/users/whaleen/repos -o _data/repos.json"
}
Run it:
npm run gh-repos