Skip to content

Instantly share code, notes, and snippets.

@sfowl
Created January 13, 2021 07:59
Show Gist options
  • Save sfowl/6dbe144b890d0687e0ae2ac38524d63f to your computer and use it in GitHub Desktop.
Save sfowl/6dbe144b890d0687e0ae2ac38524d63f to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
# prereqs and token code written by Joel Smith
allprereqs=1
for i in cat shyaml hub jq curl git; do
if ! command -v $i &> /dev/null; then
echo $?
echo "Missing prerequisite: $i"
allprereqs=0
fi
done
[ "$allprereqs" = "1" ] || exit 1
token="$(shyaml get-value github\\.com.0.oauth_token < ~/.config/hub)"
[ $? -eq 0 ] || { echo unable to get GitHub token from ~/.config/hub; exit 1; }
# Path to directory container target OWNERS + SECURITY_CONTACTS in checked out repo
DIR_PATH=$1
cat <<EOF > /tmp/all_psc_usernames
cjcullen
cji
joelsmith
lukehinds
micahhausler
swamymsft
tallclair
philips
jessfraz
jonpulsifer
liggitt
EOF
OWNERS_FILE="$DIR_PATH/OWNERS"
SEC_CONTACTS_FILE="$DIR_PATH/SECURITY_CONTACTS"
# Remove PSC members from existing security contacts
NON_PSC_CONTACTS=$(grep -v -F -f /tmp/all_psc_usernames $SEC_CONTACTS_FILE | sed 's/^#.*//')
# whitespace convention differs across OWNERS
PREFIX=$(grep -o -m1 -E '^[^\-]*\-' $OWNERS_FILE | sed 's/\-//')
echo -e "\nsecurity_contacts:"
for u in $NON_PSC_CONTACTS; do
echo "$PREFIX- github: $u"
echo "$PREFIX email: null"
echo "$PREFIX slack: null"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment