Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.sh Secret

Created February 19, 2023 17:36
Show Gist options
  • Save KyMidd/69b8b49ee2e5a0d78fd333da90408968 to your computer and use it in GitHub Desktop.
Save KyMidd/69b8b49ee2e5a0d78fd333da90408968 to your computer and use it in GitHub Desktop.
# Set child team name
unset TEAMNAME
TEAMNAME="$PROJECT"$2
echo Child team name will be $TEAMNAME
# Check if exist
unset CURL
CURL=$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/orgs/$ORG/teams/$TEAMNAME)
if [[ $(echo "$CURL" | grep "Not Found" | wc -l) -eq 1 ]]; then
echo "Team does not exist, create"
echo Creating team "$TEAMNAME"
unset CURL
CURL=$(curl -s \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/orgs/$ORG/teams \
-d "{\"name\":\"$TEAMNAME\",\"privacy\":\"closed\",\"parent_team_id\":$PARENT_TEAM_ID}" 2>&1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment