- workspace: capmetro-monitor, github-notifications, model-selector - workspace-security: vt-monitor, monitor-unauthorized - workspace-home: cron-manager, monitor-unauthorized - extensions: vt-sentinel (VT-Sentinel plugin) Includes sync.sh for pull/push, README, AGENTS.md, .gitignore.
75 lines
2.5 KiB
Bash
Executable File
75 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Auto-dismiss GitHub notifications matching certain patterns
|
|
# - Nightlies, previews, checkpoints, rc, etc (by title pattern)
|
|
# - Releases with no release notes
|
|
# Exempts specified repos from auto-dismiss
|
|
#
|
|
# Dismiss = PATCH (read) + DELETE thread + DELETE subscription
|
|
|
|
set -e
|
|
|
|
DRY_RUN="${DRY_RUN:-false}"
|
|
|
|
# Repos exempt from auto-dismiss (always show these)
|
|
EXEMPT_REPOS="Mirrowel/LLM-API-Key-Proxy|b3nw/LLM-API-Key-Proxy|pedramamini/Maestro"
|
|
|
|
# Patterns to auto-dismiss (case-insensitive)
|
|
DISMISS_PATTERNS="nightly|preview|checkpoint|pre-release|canary|alpha|beta|snapshot|-rc\.|rc[0-9]"
|
|
|
|
# Get all unread notifications
|
|
NOTIFICATIONS=$(gh api /notifications 2>/dev/null || echo "[]")
|
|
|
|
if [ "$NOTIFICATIONS" = "[]" ] || [ -z "$NOTIFICATIONS" ]; then
|
|
echo '{"dismissed":0,"checked":0}'
|
|
exit 0
|
|
fi
|
|
|
|
DISMISSED=0
|
|
TOTAL=$(echo "$NOTIFICATIONS" | jq 'length')
|
|
|
|
echo "$NOTIFICATIONS" | jq -c '.[]' | while read -r notif; do
|
|
ID=$(echo "$notif" | jq -r '.id')
|
|
TITLE=$(echo "$notif" | jq -r '.subject.title')
|
|
TYPE=$(echo "$notif" | jq -r '.subject.type')
|
|
URL=$(echo "$notif" | jq -r '.subject.url')
|
|
REPO=$(echo "$notif" | jq -r '.repository.full_name')
|
|
|
|
# Skip exempt repos
|
|
if echo "$REPO" | grep -qiE "$EXEMPT_REPOS"; then
|
|
continue
|
|
fi
|
|
|
|
SHOULD_DISMISS=false
|
|
REASON=""
|
|
|
|
# Check title patterns
|
|
if echo "$TITLE" | grep -qiE "$DISMISS_PATTERNS"; then
|
|
SHOULD_DISMISS=true
|
|
REASON="title_pattern"
|
|
fi
|
|
|
|
# Check releases with no notes
|
|
if [ "$TYPE" = "Release" ] && [ "$SHOULD_DISMISS" = "false" ]; then
|
|
RELEASE_BODY=$(gh api "$URL" --jq '.body // ""' 2>/dev/null || echo "")
|
|
if [ -z "$RELEASE_BODY" ] || [ "$RELEASE_BODY" = "null" ]; then
|
|
SHOULD_DISMISS=true
|
|
REASON="empty_release_notes"
|
|
fi
|
|
fi
|
|
|
|
if [ "$SHOULD_DISMISS" = "true" ]; then
|
|
if [ "$DRY_RUN" = "true" ]; then
|
|
echo "Would dismiss: [$REPO] $TITLE ($REASON)" >&2
|
|
else
|
|
# Full dismiss: mark read + delete thread + delete subscription
|
|
gh api -X PATCH "/notifications/threads/$ID" 2>/dev/null || true
|
|
gh api -X DELETE "/notifications/threads/$ID" 2>/dev/null || true
|
|
gh api -X DELETE "/notifications/threads/$ID/subscription" 2>/dev/null || true
|
|
echo "Dismissed: [$REPO] $TITLE ($REASON)" >&2
|
|
fi
|
|
DISMISSED=$((DISMISSED + 1))
|
|
fi
|
|
done
|
|
|
|
echo "{\"dismissed\":$DISMISSED,\"checked\":$TOTAL}"
|