Last active
October 30, 2021 15:03
-
-
Save jpigree/32d291b6c44b916ff8ce1262ff8a7311 to your computer and use it in GitHub Desktop.
Merge dependabot prs. Useful when having a lot of those PRs across multiple repositories on Github. Need to clone all target repositories in same directory first.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
REPO_DIR="$(realpath ${1:-.})" | |
for repo in $(find "$REPO_DIR" -mindepth 1 -maxdepth 1 -type d) | |
do | |
if [ ! -d "$repo/.git" ] | |
then | |
echo "Skipping $repo. Not a git repo" | |
continue | |
fi | |
( | |
cd $repo | |
url="$(gh repo view --json url --template "{{.url}}")" | |
pr_numbers="$(gh pr list -l "dependencies" --json number -q ".[] | .number")" | |
echo "Checking dependabot PRs for $url" | |
if [ -n "$pr_numbers" ] | |
then | |
for i in $pr_numbers | |
do | |
echo "Merging PR $i" | |
gh pr merge -d $i -r | |
done | |
gh run watch | |
read -p "Continue? " -n 1 -r | |
echo | |
if [[ ! $REPLY =~ ^[Yy]$ ]] | |
then | |
exit 1 | |
fi | |
else | |
echo "No dependabot PRs to merge. Continuing!" | |
fi | |
) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment