Skip to content

Commit f2ebe42

Browse files
committed
feat: Allow user to specify branch for cloning of sub-docs
ref: #10 closes #9
1 parent 5c29685 commit f2ebe42

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

includes/entrypoint.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ build_child() {
4848
child_repo_host="$1"
4949
child_repo_user="$2"
5050
child_repo_name="$3"
51+
child_repo_branch="$4"
5152
# child_repo_host="$(printf '%s\n' "$1" | envsubst)"
5253
# child_repo_user="$(printf '%s\n' "$2" | envsubst)"
5354
# child_repo_name="$(printf '%s\n' "$3" | envsubst)"
@@ -59,13 +60,23 @@ build_child() {
5960
echo "data: child_repo_user=${child_repo_user}";
6061
echo "data: child_repo_name=${child_repo_name}";
6162

62-
LATEST_TAG=$(git ls-remote --tags --sort=-v:refname ${child_repo_host}/${child_repo_user}/${child_repo_name} | sed 's#.*/##' | grep -v '\^{}' | head -n 1)
63+
if [[ -n ${child_repo_branch-} ]]; then
6364

64-
echo "Latest tag found: ${LATEST_TAG}";
65+
CLONE_REF=${child_repo_branch}
6566

66-
git clone --branch "${LATEST_TAG}" --depth=1 ${child_repo_host}/${child_repo_user}/${child_repo_name} ${HOME_DIR}/artifacts/${child_repo_user}/${child_repo_name};
67+
echo "Will Clone Branch: ${CLONE_REF}";
6768

68-
echo "Finished cloning: ${LATEST_TAG}";
69+
else
70+
71+
CLONE_REF=$(git ls-remote --tags --sort=-v:refname ${child_repo_host}/${child_repo_user}/${child_repo_name} | sed 's#.*/##' | grep -v '\^{}' | head -n 1)
72+
73+
echo "Latest tag found: ${CLONE_REF}";
74+
75+
fi
76+
77+
git clone --branch "${CLONE_REF}" --depth=1 ${child_repo_host}/${child_repo_user}/${child_repo_name} ${HOME_DIR}/artifacts/${child_repo_user}/${child_repo_name};
78+
79+
echo "Finished cloning: ${CLONE_REF}";
6980

7081
cd ${HOME_DIR}/artifacts/${child_repo_user}/${child_repo_name};
7182

@@ -136,11 +147,13 @@ if [ -n "${IS_BUILD}" ]; then
136147
user=$(printf '%s\n' "$obj" | yq -r '.user' | envsubst)
137148
host=$(printf '%s\n' "$obj" | yq -r '.host' | envsubst)
138149
path=$(printf '%s\n' "$obj" | yq -r '.path' | envsubst)
150+
branch=$(printf '%s\n' "$obj" | yq -r '.branch // ""' | envsubst)
139151

140152
build_child \
141153
${host} \
142154
${user} \
143-
${name};
155+
${name} \
156+
${branch};
144157

145158

146159
merge_child \

0 commit comments

Comments
 (0)