Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.sh Secret

Created February 19, 2023 18:28
Show Gist options
  • Save KyMidd/6020d2b516949d5a4ccd62f73d511354 to your computer and use it in GitHub Desktop.
Save KyMidd/6020d2b516949d5a4ccd62f73d511354 to your computer and use it in GitHub Desktop.
# If the repo's collection is populated, assign those permissions
if [ ! -z "$COLLECTION_NAME" ]; then
# Normalize capitalization of collection name into slug
COLLECTION_SLUG=$(echo $COLLECTION_NAME | tr '[A-Z]' '[a-z]')
GH_REPO_LOWERCASE=$(echo $GH_REPO | tr '[A-Z]' '[a-z]')
# If Collection name is UI, grant UI team admin, granting merge rights
if [[ "$COLLECTION_SLUG" == "ui" ]]; then
echo "ℹ️ Repo classified as UI"
# Admins
rest_grant_repo_permissions TEAM_SLUG='uileads' PERMISSION='admin'
# There are no other *Leads groups for UI collection
# If data repo, promote data leads to admin, granting merge rights
elif [[ "$GH_REPO" == *"database"* ]]; then
echo "ℹ️ Repo classified as Database"
# Admins
rest_grant_repo_permissions TEAM_SLUG=$DATA_LEADS_TEAM_SLUG PERMISSION='admin'
# Maintain
rest_grant_repo_permissions TEAM_SLUG=$SERVICES_LEADS_TEAM_SLUG PERMISSION='maintain'
rest_grant_repo_permissions TEAM_SLUG=$TEST_LEADS_TEAM_SLUG PERMISSION='maintain'
rest_grant_repo_permissions TEAM_SLUG=$UI_LEADS_TEAM_SLUG PERMISSION='maintain'
# If test repo, promote test to admin, granting merge rights
elif [[ "$GH_REPO" == *"test"* ]]; then
echo "ℹ️ Repo classified as Test"
#Admins
rest_grant_repo_permissions TEAM_SLUG=$TEST_LEADS_TEAM_SLUG PERMISSION='admin'
# Maintain
rest_grant_repo_permissions TEAM_SLUG=$SERVICES_LEADS_TEAM_SLUG PERMISSION='maintain'
rest_grant_repo_permissions TEAM_SLUG=$UI_LEADS_TEAM_SLUG PERMISSION='maintain'
rest_grant_repo_permissions TEAM_SLUG=$DATA_LEADS_TEAM_SLUG PERMISSION='maintain'
# If collection name doesn't match others, classify as Platform
else
echo "ℹ️ Repo classified as Services (default classification)"
# Admins
rest_grant_repo_permissions TEAM_SLUG=$SERVICES_LEADS_TEAM_SLUG PERMISSION='admin'
# Maintain
rest_grant_repo_permissions TEAM_SLUG=$TEST_LEADS_TEAM_SLUG PERMISSION='maintain'
rest_grant_repo_permissions TEAM_SLUG=$UI_LEADS_TEAM_SLUG PERMISSION='admin'
rest_grant_repo_permissions TEAM_SLUG=$DATA_LEADS_TEAM_SLUG PERMISSION='maintain'
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment