Created
July 18, 2024 13:32
-
-
Save guillego/1cfe2ac0776588b891909a795d8c3e7a to your computer and use it in GitHub Desktop.
Script to disable Github notifications for all repos in an organization
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
#!/bin/bash | |
# ./disable_org_subscriptions.sh <organization-name> | |
# Need org name as an argument | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <organization-name>" | |
exit 1 | |
fi | |
ORG_NAME=$1 | |
# Fetch all repositories in the organization, feel free to customize the limit | |
REPOS=$(gh repo list --limit 1000 $ORG_NAME --json name --jq '.[].name') | |
# Loop through each repository and disable notifications | |
# This will leave notifications in "Participating and @mentions" | |
for REPO in $REPOS; do | |
echo "Updating notifications for $ORG_NAME/$REPO" | |
gh api --silent --method DELETE -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/$ORG_NAME/$REPO/subscription | |
done | |
echo "Notifications disabled for all repositories in $ORG_NAME." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment