Created
March 11, 2026 23:49
-
-
Save clareliguori/90a5b8286c0ac6495da9f4515de1bc55 to your computer and use it in GitHub Desktop.
Clear notifications like "SoAndSo requested your review to deploy to an environment"
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
| #!/usr/bin/env bash | |
| # Clear GitHub deployment approval notifications (the "requested your review to deploy" spam) | |
| # Requires: gh CLI with notifications scope | |
| # | |
| # Usage: | |
| # gh-clear-deploy-notifications # dry-run, shows what would be cleared | |
| # gh-clear-deploy-notifications --do # actually mark them as done | |
| set -euo pipefail | |
| # Ensure gh is in PATH for cron | |
| PATH="/usr/bin:$PATH" | |
| DRY_RUN=true | |
| [[ "${1:-}" == "--do" ]] && DRY_RUN=false | |
| # Fetch deployment approval notifications via GraphQL | |
| IDS=$(gh api graphql --paginate -f query=' | |
| query($endCursor: String) { | |
| viewer { | |
| notificationThreads(first: 100, after: $endCursor, query: "reason:approval_requested") { | |
| pageInfo { hasNextPage endCursor } | |
| nodes { id } | |
| } | |
| } | |
| }' --jq '.data.viewer.notificationThreads.nodes[].id') | |
| if [[ -z "$IDS" ]]; then | |
| echo "No deployment approval notifications found." | |
| exit 0 | |
| fi | |
| COUNT=$(echo "$IDS" | wc -l | tr -d ' ') | |
| echo "Found $COUNT deployment approval notification(s)" | |
| if $DRY_RUN; then | |
| echo "Dry run - run with --do to mark these as done" | |
| exit 0 | |
| fi | |
| echo "Marking as done..." | |
| echo "$IDS" | xargs -P 20 -I {} gh api graphql -f query='mutation { markNotificationAsDone(input: {id: "{}"}) { success } }' --silent | |
| echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment