Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions gh-cli/get-enterprise-organizations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi

enterpriseslug=$1

gh api graphql --paginate -f enterpriseName="$enterpriseslug" -f query='
organizations=$(gh api graphql --paginate -f enterpriseName="$enterpriseslug" -f query='
query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
enterprise(slug: $enterpriseName) {
organizations(first: 100, after: $endCursor) {
Expand All @@ -21,4 +21,23 @@ query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
}
}
}
}' --jq '{organizations: [.data.enterprise.organizations.nodes[].login]}'
}' --jq '{organizations: [.data.enterprise.organizations.nodes[].login]}')

# Slurp and merge JSON objects
merged_organizations=$(echo "$organizations" | jq -s '{organizations: map(.organizations) | add}')

# Print the consolidated JSON object
echo "$merged_organizations" | jq .

# check to see if organizations is null - null error message is confusing otherwise
if [ -z "$organizations" ]
then
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color

# Print colored messages
echo -e "${RED}No organizations found for enterprise: $enterpriseslug${NC}"
echo -e "${RED}Check that you have the proper scopes for enterprise, e.g.: 'gh auth refresh -h github.com -s read:org -s read:enterprise'${NC}"
exit 1
fi
13 changes: 13 additions & 0 deletions gh-cli/get-organizations-apps-count.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
}
}' --jq '.data.enterprise.organizations.nodes[].login')

# check to see if organizations is null - null error message is confusing otherwise
if [ -z "$organizations" ] || [ $? -ne 0 ]
then
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color

# Print colored messages
echo -e "${RED}No organizations found for enterprise: $enterpriseslug${NC}"
echo -e "${RED}Check that you have the proper scopes for enterprise, e.g.: 'gh auth refresh -h github.com -s read:org -s read:enterprise'${NC}"
exit 1
fi

echo -e "Org\tApp Count"

for org in $organizations
Expand Down
13 changes: 13 additions & 0 deletions gh-cli/get-organizations-apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
}
}' --jq '.data.enterprise.organizations.nodes[].login')

# check to see if organizations is null - null error message is confusing otherwise
if [ -z "$organizations" ] || [ $? -ne 0 ]
then
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color

# Print colored messages
echo -e "${RED}No organizations found for enterprise: $enterpriseslug${NC}"
echo -e "${RED}Check that you have the proper scopes for enterprise, e.g.: 'gh auth refresh -h github.com -s read:org -s read:enterprise'${NC}"
exit 1
fi

if [ "$format" == "tsv" ]; then
echo -e "Org\tApp Slug\tApp ID\tCreated At\tUpdated At\tPermissions\tEvents"
fi
Expand Down
13 changes: 13 additions & 0 deletions gh-cli/get-organizations-codeowner-usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
}
}' --jq '.data.enterprise.organizations.nodes[].login')

# check to see if organizations is null - null error message is confusing otherwise
if [ -z "$organizations" ] || [ $? -ne 0 ]
then
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color

# Print colored messages
echo -e "${RED}No organizations found for enterprise: $enterpriseslug${NC}"
echo -e "${RED}Check that you have the proper scopes for enterprise, e.g.: 'gh auth refresh -h github.com -s read:org -s read:enterprise'${NC}"
exit 1
fi

for org in $organizations
do
gh api graphql --paginate --hostname $hostname -f orgName="$org" -f query='
Expand Down
13 changes: 13 additions & 0 deletions gh-cli/get-organizations-custom-repository-roles-count.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
}
}' --jq '.data.enterprise.organizations.nodes[].login')

# check to see if organizations is null - null error message is confusing otherwise
if [ -z "$organizations" ] || [ $? -ne 0 ]
then
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color

# Print colored messages
echo -e "${RED}No organizations found for enterprise: $enterpriseslug${NC}"
echo -e "${RED}Check that you have the proper scopes for enterprise, e.g.: 'gh auth refresh -h github.com -s read:org -s read:enterprise'${NC}"
exit 1
fi

echo -e "Org\tCustoim Role Count"

for org in $organizations
Expand Down
13 changes: 13 additions & 0 deletions gh-cli/get-organizations-discussions-count.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
}
}' --jq '.data.enterprise.organizations.nodes[].login')

# check to see if organizations is null - null error message is confusing otherwise
if [ -z "$organizations" ] || [ $? -ne 0 ]
then
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color

# Print colored messages
echo -e "${RED}No organizations found for enterprise: $enterpriseslug${NC}"
echo -e "${RED}Check that you have the proper scopes for enterprise, e.g.: 'gh auth refresh -h github.com -s read:org -s read:enterprise'${NC}"
exit 1
fi

for org in $organizations
do
gh api graphql --paginate --hostname $hostname -f orgName="$org" -f query='
Expand Down
13 changes: 13 additions & 0 deletions gh-cli/get-organizations-settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
}
}' --jq '.data.enterprise.organizations.nodes[].login')

# check to see if organizations is null - null error message is confusing otherwise
if [ -z "$organizations" ] || [ $? -ne 0 ]
then
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color

# Print colored messages
echo -e "${RED}No organizations found for enterprise: $enterpriseslug${NC}"
echo -e "${RED}Check that you have the proper scopes for enterprise, e.g.: 'gh auth refresh -h github.com -s read:org -s read:enterprise'${NC}"
exit 1
fi

if [ "$format" == "tsv" ]; then
echo -e "Org Login\tOrg Name\tOrg Desc\tDefault Repo Permission\tMembers Can Create Repos\t\tMembers Allowed Repos Creation Type\tMembers Can Create Public Repos\tMembers Can Create Private Repos\tMembers Can Create Internal Repos\tMembers Can Fork Private Repos"
fi
Expand Down
13 changes: 13 additions & 0 deletions gh-cli/get-organizations-webhooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ query getEnterpriseOrganizations($enterpriseName: String! $endCursor: String) {
}
}' --jq '.data.enterprise.organizations.nodes[].login')

# check to see if organizations is null - null error message is confusing otherwise
if [ -z "$organizations" ] || [ $? -ne 0 ]
then
# Define color codes
RED='\033[0;31m'
NC='\033[0m' # No Color

# Print colored messages
echo -e "${RED}No organizations found for enterprise: $enterpriseslug${NC}"
echo -e "${RED}Check that you have the proper scopes for enterprise, e.g.: 'gh auth refresh -h github.com -s read:org -s read:enterprise'${NC}"
exit 1
fi

if [ "$format" == "tsv" ]; then
echo -e "Organization\tActive\tURL\tCreated At\tUpdated At\tEvents"
fi
Expand Down