File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # This section loads configuration files needed to set environment variables
4+ # such as GITHUB_TOKEN. If these variables are already exported globally in the shell,
5+ # the files below can remain commented out. Otherwise, uncomment the appropriate
6+ # file(s) as needed. This particular script only needs GITHUB_TOKEN to function properly.
7+
8+ # source "$GITNAP/utils/auth.sh"
9+ # source "$GITNAP/utils/settings.sh"
10+
11+
12+ function list_github_repo() {
13+ local endpoint
14+ local response
15+ local tmp_file
16+
17+ endpoint=" https://api.github.com/user/repos?per_page=100"
18+ tmp_file=$( mktemp)
19+
20+ # Get all repositories
21+ while [ " $endpoint " ]; do
22+ repos=$( curl -sSL -H " Authorization: token $GITHUB_TOKEN " " $endpoint " )
23+ echo " $repos " >> " $tmp_file "
24+
25+ # Iterate through each repository in the response
26+ for repo_url in $( echo " $repos " | jq -r ' .[].url' ) ; do
27+ response=$( curl -sSL -H " Authorization: token $GITHUB_TOKEN " " $repo_url " )
28+ echo " $response " >> " $tmp_file "
29+ done
30+
31+ # Check for more pages
32+ endpoint=$( curl -sSL -I -H " Authorization: token $GITHUB_TOKEN " " $endpoint " | grep -i ' ^link:' | sed -n ' s/.*<\(.*\)>; rel="next".*/\1/p' )
33+ done
34+
35+ less " $tmp_file "
36+ rm " $tmp_file "
37+
38+ }
39+
40+ list_github_repo
You can’t perform that action at this time.
0 commit comments