GitHub Repo Management Resources
This page might be better off as a blog...
Setting Up¶
The following items can be helpful when managing multiple GitHub repos:
- A
.jsonrepo inventory file - Variables or an
.envfile - An inventory array, sourced from the
.jsonrepo inventory file
Repo Inventory File¶
In this case, we are using a .json file to keep track of the GitHub repos that will be managed.
Here are the contents of the repo-list.json file:
Variables¶
Set variables and "reset" the secrets inventory list:
- Set the
repoOwnervariable toyourusername
Inventory array¶
We will first create an array of repos from the ./repo-list.json file
1. Verify inventory output from jq¶
-
Run the following
jqcommand to test the format of the JSON file: -
Review the output from the command to make sure the repos output the proper format:
2. Create the inventory array¶
Create the array using either bash or zsh
Create the inventory array using bash¶
# Create the variable that contains the array:
arrayAsString=$(jq --raw-output '.repo | to_entries | map("[\(.key)]=\(.value)") | reduce .[] as $item ("myRepos=("; . + $item + " ") + ")"' ./repo-list.json)
# Declare the array:
declare -A "$arrayAsString"
Create the inventory array using zsh¶
# Declare the array:
typeset -A myRepos
# Create the variable that contains the array:
arrayAssignments=$(jq -r '.repo | to_entries[] | "myRepos[\(.key)]=\(.value)"' ./repo-list.json)
3. Test the inventory array¶
Test the array using either bash or zsh: