From e807cc7468f9cc4a94c72531c60095b57e012706 Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Sun, 28 Jan 2024 17:10:28 -0500 Subject: [PATCH] Add CI jobs to manage ArgoCD review environments --- .gitlab-ci.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2361f47..ef998d5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,3 +36,36 @@ cargo-doc: artifacts: paths: - target/doc + +.argocd: + image: argoproj/argocd:v2.6.15 + before_script: + - argocd login ${ARGOCD_SERVER} --username ${ARGOCD_USERNAME} --password ${ARGOCD_PASSWORD} --grpc-web + +# Start the review environment +start-review: + extends: .argocd + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + when: manual + script: + - argocd app sync argocd/libretunes-review-${CI_COMMIT_SHORT_SHA} + - argocd app wait argocd/libretunes-review-${CI_COMMIT_SHORT_SHA} + environment: + name: review/$CI_COMMIT_SHORT_SHA + url: https://review-$CI_COMMIT_SHORT_SHA.libretunes.mregirouard.com + on_stop: stop-review + +# Stop the review environment +stop-review: + needs: ["start-review"] + extends: .argocd + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + when: manual + allow_failure: true + script: + - argocd app delete argocd/libretunes-review-${CI_COMMIT_SHORT_SHA} --cascade + environment: + name: review/$CI_COMMIT_SHORT_SHA + action: stop