Skip to content

Commit d762c7a

Browse files
committed
feat(bind9): git-ops Add support for specifying tags to fetch latest tag always
ref: #21
1 parent f809d7b commit d762c7a

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

manifests/bind9/components/git-ops/Deployment.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)