Created
June 17, 2021 12:51
-
-
Save rnorth/17cbcc8909e14f207f6dd0e1088d4888 to your computer and use it in GitHub Desktop.
Script to clean up GitHub notifications by marking all notifications for merged/closed Dependabot PR as read
This file contains hidden or 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 | |
gh api notifications --paginate --jq '.[] | [.subject.url,.url] | @tsv' | while read -r URL THREAD_URL; do | |
ITEM=$(gh api $URL) | |
NUMBER=$(jq -r .number <<< ${ITEM}) | |
TITLE=$(jq -r .title <<< ${ITEM}) | |
STATE=$(jq -r .state <<< ${ITEM}) | |
echo "$NUMBER $TITLE $STATE" | |
# Pattern match on title so that we only touch things that look like Dependabot PRs | |
# Customize according to need! | |
if [[ "$STATE" == "closed" && "$TITLE" =~ Bump.* ]]; then | |
echo "Marking closed item #$NUMBER as read: $TITLE" | |
gh api -X PATCH $THREAD_URL | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment