Skip to content

Commit c21eaec

Browse files
author
Ahmad Iqbal
committed
add option to checkout revision
1 parent 76b858a commit c21eaec

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,4 @@ RUN chgrp -R 0 /root && \
2020
# Clean up
2121
RUN apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2222

23-
USER $USER
24-
2523
CMD ["/init.sh"]

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ It is also required to mount a volume where the repository will be cloned from l
1818
In case of private repositories you also have to mount deployment SSH key authorized to clone code repository
1919

2020
### optional
21-
`TAG` - clone specified tag
21+
`REPO_TAG` - checkout specified tag
2222

23-
`BRANCH` - clone specified branch (defaults to master)
23+
`REPO_REVISION` - checkout specified revision
24+
25+
`REPO_BRANCH` - clone specified branch (defaults to master)
2426

2527
`REPO_KEY` - RSA key filename (defaults to id_rsa)
2628

init.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ fi
1515

1616
echo "repository : $REPO_LINK"
1717
echo "branch : $REPO_BRANCH"
18+
echo "tag : $REPO_TAG"
19+
echo "revision : $REPO_REVISION"
1820
# check if credentials files exist
1921
if [[ -f "/key/$REPO_KEY" ]] ; then
2022
echo "key file : $REPO_KEY"
@@ -27,12 +29,14 @@ if [ ! -z "$REPO_USER" ] && [ ! -z "$REPO_PASS" ]; then
2729
# clone with repository username & password
2830
echo "credentials: username and password"
2931
git clone -b $REPO_BRANCH https://$REPO_USER:$REPO_PASS@$REPO_LINK /repository
30-
elif [[ ! -f "/root/.ssh/id_rsa" ]] ; then
31-
echo -e "\033[1;91mERROR:\033[0m REPO_USER, REPO_PASS env variables or SSH deployment key missing"
32-
exit 1
3332
else
34-
# clone public repository or using ssh deployment key
35-
echo "credentials: RSA key"
33+
if [[ ! -f "/root/.ssh/id_rsa" ]] ; then
34+
echo -e "\033[1;93mWARNING:\033[0m REPO_USER, REPO_PASS env variables or SSH deployment key missing"
35+
else
36+
# clone public repository or using ssh deployment key
37+
echo "credentials: RSA key"
38+
fi
39+
ls -lah /repository
3640
git clone -b $REPO_BRANCH $REPO_LINK /repository
3741
fi
3842

@@ -42,3 +46,8 @@ if [ ! -z "$REPO_TAG" ]; then
4246
git checkout tags/$REPO_TAG
4347
fi
4448

49+
if [ ! -z "$REPO_REVISION" ]; then
50+
cd /repository && \
51+
echo "checking out repository revision: $REPO_REVISION"
52+
git checkout $REPO_REVISION
53+
fi

0 commit comments

Comments
 (0)