-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_repo.sh
executable file
·50 lines (42 loc) · 1.03 KB
/
get_repo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
: "${KEY_FILE:="indigobravo"}"
: "${REMOTE:="[email protected]:indigobravo/bin.git"}"
: "${BRANCH:="main"}"
function usage() {
echo "Usage: $(basename "$0")"
echo
echo "Clone a private GitHub repository using SSH. Defaults to:"
echo " - indigobravo/bin"
echo
echo "Override environment variables as required..."
echo
echo "KEY_FILE"
echo "A private SSH key. The public part will have been added to"
echo "GitHub as a deploy key"
echo
echo "REMOTE"
echo "The full URL of the remote repository including the user"
echo
echo "BRANCH"
echo "The branch of the GitHub repository to be cloned."
}
if [[ "$#" -ge 1 ]]; then
usage >&2
exit 1
fi
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
usage
exit
fi
if [ -f $KEY_FILE ] ; then
eval "$(ssh-agent -s)"
ssh-add "$KEY_FILE"
else
echo "failed to locate: $KEY_FILE" >&2
exit 2
fi
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
git clone --branch $BRANCH $REMOTE