Skip to content

Commit 552906f

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

1 file changed

Lines changed: 45 additions & 4 deletions

File tree

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

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,24 @@ spec:
5151
5252
git reset --hard;
5353
54-
echo "Pulling any changes....";
54+
if [ "${SSH_REPOSITORY_REF}"=="tag" ]; then
55+
56+
echo "`tag` or nothing supplied for variable SSH_REPOSITORY_REF, fetching latest git tag to use.";
57+
58+
SSH_REPOSITORY_REF=$(git ls-remote --tags --sort=-v:refname git@${REPO_NAME_FULL} | sed 's#.*/##' | grep -v '\^{}' | head -n 1);
59+
60+
echo "Using SSH_REPOSITORY_REF=[${SSH_REPOSITORY_REF}]";
61+
62+
git checkout "${SSH_REPOSITORY_REF}"
63+
64+
else
65+
66+
echo "Pulling any changes....";
67+
68+
git pull --rebase
69+
70+
fi
5571
56-
git pull --rebase
5772
5873
else
5974
@@ -160,6 +175,15 @@ spec:
160175
161176
echo "Clonning repo on branch=[${SSH_REPOSITORY_REF}]";
162177
178+
if [ "${SSH_REPOSITORY_REF}"=="tag" ]; then
179+
180+
echo "`tag` or nothing supplied for variable SSH_REPOSITORY_REF, fetching latest git tag to use.";
181+
182+
SSH_REPOSITORY_REF=$(git ls-remote --tags --sort=-v:refname git@${REPO_NAME_FULL} | sed 's#.*/##' | grep -v '\^{}' | head -n 1)
183+
184+
fi
185+
186+
163187
git clone -b "${SSH_REPOSITORY_REF}" git@${REPO_NAME_FULL} /git;
164188
165189
else
@@ -191,9 +215,25 @@ spec:
191215
192216
git reset --hard;
193217
194-
echo "Pulling any changes....";
195218
196-
git pull --rebase
219+
if [ "${SSH_REPOSITORY_REF}"=="tag" ]; then
220+
221+
echo "`tag` or nothing supplied for variable SSH_REPOSITORY_REF, fetching latest git tag to use.";
222+
223+
SSH_REPOSITORY_REF=$(git ls-remote --tags --sort=-v:refname git@${REPO_NAME_FULL} | sed 's#.*/##' | grep -v '\^{}' | head -n 1)
224+
225+
echo "Using SSH_REPOSITORY_REF=[${SSH_REPOSITORY_REF}]";
226+
227+
git checkout "${SSH_REPOSITORY_REF}"
228+
229+
else
230+
231+
echo "Pulling any changes....";
232+
233+
git pull --rebase
234+
235+
fi
236+
197237
198238
else
199239
@@ -204,6 +244,7 @@ spec:
204244
205245
fi
206246
247+
207248
echo "Finish init";
208249
209250
env:

0 commit comments

Comments
 (0)