From 7f53e2c303dbdc07825e7c803959209119464516 Mon Sep 17 00:00:00 2001 From: moilanik Date: Mon, 22 Jun 2026 05:43:00 +0300 Subject: [PATCH] jos jo haluttu versio - ei commit --- scripts/gitops-update.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/gitops-update.sh b/scripts/gitops-update.sh index 87c4f88..cd1ada1 100755 --- a/scripts/gitops-update.sh +++ b/scripts/gitops-update.sh @@ -53,6 +53,22 @@ _gitops_success() { "${context}" "" "${SOURCE_URL}" } +_gitops_nochange() { + local env repo context + env=$(dirname "${INPUT_FILE}") + repo=$(basename "${SOURCE_REPO}") + context="${repo}" + [ -n "${GIT_TAG_PREFIX:-}" ] && context="${repo}/${GIT_TAG_PREFIX}" + + local SOURCE_URL="${GITEA_API_URL}/${SOURCE_REPO}/commit/${SOURCE_COMMIT}" + + ROOT_REPO="${GITOPS_REPO}" ROOT_COMMIT="${SOURCE_COMMIT}" \ + GITEA_API_URL="${GITEA_API_URL}" GITEA_TOKEN="${GITEA_TOKEN}" \ + bash "${SCRIPT_DIR}/report-status.sh" success \ + "Install to ${env} ${VERSION} — no change" \ + "${context}" "" "${SOURCE_URL}" +} + _gitops_substitute() { echo "$1" | sed "s/{{VERSION}}/$2/g" } @@ -69,6 +85,14 @@ _gitops_update() { cd "${CLONE_DIR}" || _gitops_fail "Failed to enter clone directory" yq eval -i "${YQ_EXPR}" "${INPUT_FILE}" || _gitops_fail "Failed to update ${INPUT_FILE}" git add "${INPUT_FILE}" || _gitops_fail "Failed to stage ${INPUT_FILE}" + + if git diff --cached --quiet; then + echo "No changes — ${INPUT_FILE} already at ${VERSION}" + GITOPS_SHA="$(git rev-parse HEAD)" + _gitops_nochange + exit 0 + fi + git -c user.name="gitea-ci-bot" \ -c user.email="ci@keskikuja.site" \ commit -m "[skip ci] gitops: update version to ${VERSION}" || _gitops_fail "Failed to commit"