From ed1fb1b776a2270f961feedb9ace606dec5bf6bb Mon Sep 17 00:00:00 2001 From: M1 AIR Date: Thu, 5 Mar 2026 00:33:11 +0700 Subject: [PATCH] ci: add dev gitops trigger after dev build --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e97d5455..b665db17 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -85,6 +85,40 @@ build_push_dev: docker build -f Dockerfile -t "$ECR_REPOSITORY:$IMAGE_TAG" . docker push "$ECR_REPOSITORY:$IMAGE_TAG" +update_gitops_dev_lti: + stage: gitops + image: public.ecr.aws/docker/library/alpine:3.20 + tags: [self-hosted-dev] + rules: + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "development"' + needs: ["build_push_dev"] + variables: + IMAGE_TAG: "dev-${CI_COMMIT_SHORT_SHA}" + GITOPS_BRANCH: main + VALUES_FILE: environments/lti/dev/lti-values-dev.yaml + GITOPS_REPO_URL: https://oauth2:${GITOPS_TOKEN}@gitlab.com/cristian.anggita.parjaman/gitops.git + before_script: + - set -eu + - apk add --no-cache git yq + - git config --global user.email "ci@gitlab" + - git config --global user.name "gitlab-ci" + script: | + set -eu + rm -rf gitops + git clone --depth 1 --branch "$GITOPS_BRANCH" "$GITOPS_REPO_URL" gitops + cd gitops + + echo "Updating dev image.tag to $IMAGE_TAG" + yq -i '.image.tag = strenv(IMAGE_TAG)' "$VALUES_FILE" + + git add "$VALUES_FILE" + if git diff --cached --quiet; then + echo "No changes to commit" + exit 0 + fi + git commit -m "lti dev deploy ${IMAGE_TAG}" + git push origin "$GITOPS_BRANCH" + # ========================= # PRODUCTION (push branch production) # =========================