Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.sh Secret

Created November 20, 2022 18:58
Show Gist options
  • Save KyMidd/846b944fb176dde791ba88b8df78677f to your computer and use it in GitHub Desktop.
Save KyMidd/846b944fb176dde791ba88b8df78677f to your computer and use it in GitHub Desktop.
# If COLLECTION_LEAD_TEAM_GITHUB_SLUG blank, skip it
if [ -z "$COLLECTION_LEAD_TEAM_GITHUB_SLUG" ]; then
# No collection lead team specified, will skip this step
echo "COLLECTION_LEAD_TEAM_GITHUB_SLUG is blank, not setting that permission"
else
# Collection lead team specified, check if exists
unset CURL
CURL=$(curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/orgs/$GH_ORG/teams/$COLLECTION_LEAD_TEAM_GITHUB_SLUG 2>&1)
if [[ $(echo "$CURL" | grep -E "Problems|Not Found") ]]; then
# Team doesn't exist or slug is wrong
echo "☠️ The collection lead slug isn't correct, that team doesn't exist. Continuing, but won't set this permission. Error message:"
echo "$CURL"
# Unset this value so we don't attempt to set this permission below, as it will fail
unset COLLECTION_LEAD_TEAM_GITHUB_SLUG
else
# Leads team specified and does exist
echo "Setting the collection lead team permissions for team: $COLLECTION_LEAD_TEAM_GITHUB_SLUG"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment