-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add script to merge dependabot PRs
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# set -x # TO REMOVE | ||
|
||
set -euo pipefail | ||
|
||
request_approval_to_continue() { | ||
echo | ||
echo $1 | ||
echo | ||
echo 'Continue with PR approval and merge? Only "yes" will be accepted to approve.' | ||
read CONTINUE | ||
[ "$CONTINUE" == "yes" ] || exit 0 | ||
} | ||
|
||
show_help () { | ||
echo Usage: $0 | ||
echo | ||
echo Iterate over open and mergeable dependabot PRs to approve and merge them. | ||
exit 0 | ||
} | ||
|
||
# Show help if needed | ||
([ "${1:-}" == "-h" ] || [ "${1:-}" == "--help" ]) && show_help | ||
|
||
# Ensure we are on master branch | ||
[ "$(git rev-parse --abbrev-ref HEAD)" == "master" ] || (echo ERROR: not on "master" branch, aborting. ; exit 1) | ||
|
||
while true ; do | ||
gh pr list --state open --label dependencies --json title,mergeable,number,updatedAt | ||
GH_PR=$(gh pr list --state open --label dependencies --json title,mergeable,number,updatedAt | jq -r '.[] | select(.mergeable == "MERGEABLE") | .number' | sort -n | head -n 1); echo PR \#$GH_PR ; gh pr diff $GH_PR || break | ||
|
||
request_approval_to_continue "Please review above diff." | ||
gh pr review $GH_PR --approve | ||
gh pr merge $GH_PR --merge --delete-branch | ||
done | ||
|
||
# Pull from github | ||
git pull |