Skip to content

Commit dda439f

Browse files
Merge pull request #203 from shiftstack/ssh_keys
Add team_ssh_keys.sh
2 parents c23415b + 03f4fe3 commit dda439f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

team_ssh_keys.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# This script will generate a temporary file with all the ssh keys of the
3+
# approvers of a given team name in the OWNERS_ALIASES file of a given project.
4+
# The script will return the path of the temporary file.
5+
# The script will return 1 if the script fails to curl the OWNER_ALIASES file
6+
# or if the yq command is not found.
7+
8+
set -Eeuo pipefail
9+
10+
GITHUB_PROJECT="${GITHUB_PROJECT:-openshift/installer}"
11+
TEAM_NAME="${TEAM_NAME:-openstack-approvers}"
12+
13+
if ! command -v yq &> /dev/null; then
14+
echo "yq could not be found"
15+
echo "https://github.com/mikefarah/yq"
16+
exit 1
17+
fi
18+
19+
OWNER_ALIASES=$(curl -s "https://raw.githubusercontent.com/${GITHUB_PROJECT}/master/OWNERS_ALIASES")
20+
if [ -z "$OWNER_ALIASES" ]; then
21+
echo "Failed to curl the OWNER_ALIASES from ${GITHUB_PROJECT}"
22+
exit 1
23+
fi
24+
25+
# shellcheck disable=SC2016
26+
MEMBERS=$(echo "$OWNER_ALIASES" | yq --arg team_name "$TEAM_NAME" -r '.aliases[$team_name] | join(" ")')
27+
28+
TMP_FILE=$(mktemp)
29+
for member in $MEMBERS; do
30+
curl -s "https://github.com/$member.keys" >> "$TMP_FILE"
31+
done
32+
33+
echo "$TMP_FILE"

0 commit comments

Comments
 (0)