Skip to content

Instantly share code, notes, and snippets.

@gitstua
Last active February 6, 2023 10:18
Show Gist options
  • Save gitstua/9d95d4bbca1b98ed744b0f5dcb1ac67f to your computer and use it in GitHub Desktop.
Save gitstua/9d95d4bbca1b98ed744b0f5dcb1ac67f to your computer and use it in GitHub Desktop.
#!/bin/bash
## CAUTION: provided without warranty - use at own risk
# thanks https://gist.github.com/narze/2c2e141f03daea2c23fc5795107d41d4
ORG="gitstua"
DISCUSSION_SETTING="true"
# Get repos
REPOS=($(gh repo list $ORG --limit 200 --json name --json owner -q '.[] | "\(.owner.login)/\(.name)"'
))
for REPO in "${REPOS[@]}"; do
echo "Updated repo ${REPO} Org:$ORG to has_discussions:$DISCUSSION_SETTING"
#enable or disable discussions
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/$REPO \
-F has_discussions=$DISCUSSION_SETTING
echo "\n============================================================\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment