From eb41e63210e24e18ba69311c40212178382bd53b Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Thu, 7 Aug 2025 10:46:41 -0500 Subject: [PATCH] feat: add script to find repositories using Dependabot version updates --- gh-cli/README.md | 12 +++++ ...tories-using-dependabot-version-updates.sh | 45 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 gh-cli/get-repositories-using-dependabot-version-updates.sh diff --git a/gh-cli/README.md b/gh-cli/README.md index 011e1bc..999dbba 100644 --- a/gh-cli/README.md +++ b/gh-cli/README.md @@ -1043,6 +1043,18 @@ Get repositories that have a CircleCI configuration file `.circleci/config.yml` Get repositories that have a CodeQL configuration file `.github/workflows/codeql.yml` +### get-repositories-using-dependabot-version-updates.sh + +Get repositories that have Dependabot version updates configured by checking for the presence of a `.github/dependabot.yml` file. + +Usage: + +```shell +./get-repositories-using-dependabot-version-updates.sh my-org +``` + +Returns a simple list of repository names followed by a count summary. + ### get-repositories-webhooks-csv.sh Gets a CSV with the list of repository webhooks in a GitHub organization. diff --git a/gh-cli/get-repositories-using-dependabot-version-updates.sh b/gh-cli/get-repositories-using-dependabot-version-updates.sh new file mode 100755 index 0000000..2343adc --- /dev/null +++ b/gh-cli/get-repositories-using-dependabot-version-updates.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Get repositories using Dependabot version updates +# This script finds all repositories in an organization that have a .github/dependabot.yml file +# Usage: ./get-repositories-using-dependabot-version-updates.sh + +if [ -z "$1" ] + then + echo "Usage: $0 " + echo "Example: ./get-repositories-using-dependabot-version-updates.sh my-org" + exit 1 +fi + +org=$1 + +echo "🔍 Searching for repositories with Dependabot configuration in '$org'..." +echo "" + +repositories=$(gh api graphql --paginate -F owner="$org" -f query=' + query ($owner: String!, $endCursor: String) { + organization(login: $owner) { + repositories(first: 100, after: $endCursor) { + nodes { + name + object(expression: "HEAD:.github/dependabot.yml") { + id + } + } + pageInfo { + endCursor + hasNextPage + } + } + } + }' --jq '.data.organization.repositories.nodes[] | select(.object) | .name' | tr -d '"') + +if [ -z "$repositories" ]; then + echo "❌ No repositories found with Dependabot configuration in '$org'" + exit 0 +fi + +echo "$repositories" +echo "" +count=$(echo "$repositories" | wc -l | tr -d ' ') +echo "Total: $count repositories with Dependabot configuration"