-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.sh
executable file
·47 lines (39 loc) · 931 Bytes
/
action.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
#!/usr/bin/env bash
set -xe;
repository=$1;
ref=$2;
path=$3;
fetchDepth=$4;
submodules=$5;
THIS_SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"`;
THIS_SCRIPT_DIR=`realpath "${THIS_SCRIPT_DIR}"`;
echo "##[group] Cloning $repository";
if [[ $repository == https://* ]] || [[ $repository == git@* ]]
then :
else
repository=https://github.com/${repository};
fi;
if [ -z "${path}" ]; then
repoName=$(python3 $THIS_SCRIPT_DIR/getRepoName.py ${repository});
path=$(realpath $repoName);
fi;
prevCWD=$PWD;
if [ -z "${ref}" ]; then
git clone --depth=${fetchDepth} ${repository} ${path};
cd ${path};
else
remoteName=origin;
mkdir -p ${path};
cd ${path};
git init;
git remote add ${remoteName} ${repository};
git fetch origin ${ref} --depth=${fetchDepth};
git checkout ${ref};
fi
if [ -z "${submodules}" ] || [ "${submodules}" -eq "0" ]; then
:
else
git submodule update --init --recursive;
fi;
cd $prevCWD;
echo "##[endgroup]";