File tree Expand file tree Collapse file tree
manifests/bind9/components/git-ops Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,6 +160,15 @@ spec:
160160
161161 echo "Clonning repo on branch=[${SSH_REPOSITORY_REF}]";
162162
163+ if [ "${SSH_REPOSITORY_REF}"=="tag" ]; then
164+
165+ echo "`tag` or nothing supplied for variable SSH_REPOSITORY_REF, fetching latest git tag to use.";
166+
167+ SSH_REPOSITORY_REF=$(git ls-remote --tags --sort=-v:refname git@${REPO_NAME_FULL} | sed 's#.*/##' | grep -v '\^{}' | head -n 1)
168+
169+ fi
170+
171+
163172 git clone -b "${SSH_REPOSITORY_REF}" git@${REPO_NAME_FULL} /git;
164173
165174 else
@@ -191,9 +200,23 @@ spec:
191200
192201 git reset --hard;
193202
194- echo "Pulling any changes....";
195203
196- git pull --rebase
204+ if [ "${SSH_REPOSITORY_REF}"=="tag" ]; then
205+
206+ echo "`tag` or nothing supplied for variable SSH_REPOSITORY_REF, fetching latest git tag to use.";
207+
208+ SSH_REPOSITORY_REF=$(git ls-remote --tags --sort=-v:refname git@${REPO_NAME_FULL} | sed 's#.*/##' | grep -v '\^{}' | head -n 1)
209+
210+ git checkout "${SSH_REPOSITORY_REF}"
211+
212+ else
213+
214+ echo "Pulling any changes....";
215+
216+ git pull --rebase
217+
218+ fi
219+
197220
198221 else
199222
@@ -204,6 +227,7 @@ spec:
204227
205228 fi
206229
230+
207231 echo "Finish init";
208232
209233 env :
You can’t perform that action at this time.
0 commit comments