Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.sh Secret

Created April 12, 2024 19:47
Show Gist options
  • Select an option

  • Save KyMidd/1a2ce47dc5378f50bd47395e1a1a27a1 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/1a2ce47dc5378f50bd47395e1a1a27a1 to your computer and use it in GitHub Desktop.
# Remove user from copilot
remove_user_from_copilot() {
REMOVE_USER_FROM_COPILOT=$(curl -sL \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/$gh_org/copilot/billing/selected_users \
-d "{\"selected_usernames\":[\"$copilot_user\"]}")
# If response contains json key seats_cancelled, it worked
if [[ $REMOVE_USER_FROM_COPILOT == *"seats_cancelled"* ]]; then
echo "✅ User $copilot_user removed from CoPilot"
else
echo "❌ Failed to remove user $copilot_user from CoPilot, please investigate:"
echo "$REMOVE_USER_FROM_COPILOT"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment