Feature/gitops #37
@@ -53,6 +53,22 @@ _gitops_success() {
|
|||||||
"${context}" "" "${SOURCE_URL}"
|
"${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() {
|
_gitops_substitute() {
|
||||||
echo "$1" | sed "s/{{VERSION}}/$2/g"
|
echo "$1" | sed "s/{{VERSION}}/$2/g"
|
||||||
}
|
}
|
||||||
@@ -69,6 +85,14 @@ _gitops_update() {
|
|||||||
cd "${CLONE_DIR}" || _gitops_fail "Failed to enter clone directory"
|
cd "${CLONE_DIR}" || _gitops_fail "Failed to enter clone directory"
|
||||||
yq eval -i "${YQ_EXPR}" "${INPUT_FILE}" || _gitops_fail "Failed to update ${INPUT_FILE}"
|
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}"
|
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" \
|
git -c user.name="gitea-ci-bot" \
|
||||||
-c user.email="ci@keskikuja.site" \
|
-c user.email="ci@keskikuja.site" \
|
||||||
commit -m "[skip ci] gitops: update version to ${VERSION}" || _gitops_fail "Failed to commit"
|
commit -m "[skip ci] gitops: update version to ${VERSION}" || _gitops_fail "Failed to commit"
|
||||||
|
|||||||
Reference in New Issue
Block a user