Skip to content

Commit 891dd7b

Browse files
feat: add script to find repositories using Dependabot version updates (#109)
1 parent 60d1927 commit 891dd7b

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

gh-cli/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,18 @@ Get repositories that have a CircleCI configuration file `.circleci/config.yml`
10431043

10441044
Get repositories that have a CodeQL configuration file `.github/workflows/codeql.yml`
10451045

1046+
### get-repositories-using-dependabot-version-updates.sh
1047+
1048+
Get repositories that have Dependabot version updates configured by checking for the presence of a `.github/dependabot.yml` file.
1049+
1050+
Usage:
1051+
1052+
```shell
1053+
./get-repositories-using-dependabot-version-updates.sh my-org
1054+
```
1055+
1056+
Returns a simple list of repository names followed by a count summary.
1057+
10461058
### get-repositories-webhooks-csv.sh
10471059

10481060
Gets a CSV with the list of repository webhooks in a GitHub organization.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# Get repositories using Dependabot version updates
4+
# This script finds all repositories in an organization that have a .github/dependabot.yml file
5+
# Usage: ./get-repositories-using-dependabot-version-updates.sh <org>
6+
7+
if [ -z "$1" ]
8+
then
9+
echo "Usage: $0 <org>"
10+
echo "Example: ./get-repositories-using-dependabot-version-updates.sh my-org"
11+
exit 1
12+
fi
13+
14+
org=$1
15+
16+
echo "🔍 Searching for repositories with Dependabot configuration in '$org'..."
17+
echo ""
18+
19+
repositories=$(gh api graphql --paginate -F owner="$org" -f query='
20+
query ($owner: String!, $endCursor: String) {
21+
organization(login: $owner) {
22+
repositories(first: 100, after: $endCursor) {
23+
nodes {
24+
name
25+
object(expression: "HEAD:.github/dependabot.yml") {
26+
id
27+
}
28+
}
29+
pageInfo {
30+
endCursor
31+
hasNextPage
32+
}
33+
}
34+
}
35+
}' --jq '.data.organization.repositories.nodes[] | select(.object) | .name' | tr -d '"')
36+
37+
if [ -z "$repositories" ]; then
38+
echo "❌ No repositories found with Dependabot configuration in '$org'"
39+
exit 0
40+
fi
41+
42+
echo "$repositories"
43+
echo ""
44+
count=$(echo "$repositories" | wc -l | tr -d ' ')
45+
echo "Total: $count repositories with Dependabot configuration"

0 commit comments

Comments
 (0)