File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ In case of private repositories you also have to mount deployment SSH key author
20
20
### optional
21
21
` TAG ` - clone specified tag
22
22
23
- ` BRANCH ` - clone specified branch
23
+ ` BRANCH ` - clone specified branch (defaults to master)
24
+
25
+ ` REPO_KEY ` - RSA key filename (defaults to id_rsa)
24
26
25
27
if cloning using repository username/password instead SSH deployment key, please provide ` REPO_LINK ` without leading ` https:// `
26
28
@@ -32,9 +34,9 @@ if cloning using repository username/password instead SSH deployment key, please
32
34
## Example run
33
35
34
36
```
35
- docker --rm run -ti \
37
+ docker run --rm -ti \
36
38
-v /path/to/clone/repository:/repository \
37
- -v /path/to/authorized/id_rsa:/root/.ssh/id_rsa \
39
+ -v /path/to/authorized/id_rsa:/key:ro \
38
40
-e REPO_LINK=crunchgeek/git-clone
39
41
-e REPO_BRANCH=master
40
42
-e REPO_TAG=1.0.0
Original file line number Diff line number Diff line change @@ -9,24 +9,35 @@ if [ -z "$REPO_BRANCH" ]; then
9
9
export REPO_BRANCH=master
10
10
fi
11
11
12
+ if [ -z " $REPO_KEY " ]; then
13
+ export REPO_KEY=id_rsa
14
+ fi
15
+
16
+ echo " repository : $REPO_LINK "
17
+ echo " branch : $REPO_BRANCH "
12
18
# check if credentials files exist
13
- if [[ -f " /root/.ssh/id_rsa" ]] ; then
19
+ if [[ -f " /key/$REPO_KEY " ]] ; then
20
+ echo " key file : $REPO_KEY "
21
+ cp /key/$REPO_KEY /root/.ssh/id_rsa
14
22
chmod 600 /root/.ssh/id_rsa
15
23
fi
16
24
17
25
if [ ! -z " $REPO_USER " ] && [ ! -z " $REPO_PASS " ]; then
18
26
# clone with repository username & password
27
+ echo " credentials: username and password"
19
28
git clone -b $REPO_BRANCH https://$REPO_USER :$REPO_PASS @$REPO_LINK /repository
20
29
elif [[ ! -f " /root/.ssh/id_rsa" ]] ; then
21
30
echo -e " \033[1;91mERROR:\033[0m REPO_USER, REPO_PASS env variables or SSH deployment key missing"
22
31
exit 1
23
32
else
24
33
# clone public repository or using ssh deployment key
34
+ echo " credentials: RSA key"
25
35
git clone -b $REPO_BRANCH $REPO_LINK /repository
26
36
fi
27
37
28
38
if [ ! -z " $REPO_TAG " ]; then
29
39
cd /repository && \
40
+ echo " checking out repository tag: $REPO_TAG "
30
41
git checkout tags/$REPO_TAG
31
42
fi
32
43
You can’t perform that action at this time.
0 commit comments