Skip to content

Instantly share code, notes, and snippets.

@rnorth
Created June 17, 2021 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnorth/17cbcc8909e14f207f6dd0e1088d4888 to your computer and use it in GitHub Desktop.
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
#!/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