diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ddc270131be179500aa5b8f64ea2efb7e6b2d33c..41e265abace955565390711627733a3fbd2447cc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,14 +35,56 @@ docker build: paths: - DIGESTFILE -deploy docker image: +.deploy: stage: deploy + image: line/kubectl-kustomize:latest tags: - teckids-trusted - image: line/kubectl-kustomize:latest - script: + before_script: - echo $KUBECONFIG | base64 -d > /tmp/kubeconfig + +deploy production: + extends: .deploy + environment: + name: production + url: https://teckids.org + script: - cd deploy/overlays/production - - kustomize edit set image registry.edugit.org/teckids/team-pr/teckids.org:$(cat ../../../DIGESTFILE) - - kustomize build | envsubst >output.yaml + - kustomize edit set image registry.edugit.org/teckids/team-pr/teckids.org:$CI_COMMIT_REF_NAME@$(cat ../../../DIGESTFILE) + - kustomize build | envsubst > output.yaml - kubectl --kubeconfig=/tmp/kubeconfig apply -f output.yaml + only: + - master + +deploy review: + extends: .deploy + script: deploy_review + environment: + name: review/$CI_COMMIT_REF_SLUG + url: https://$CI_COMMIT_REF_SLUG.review.teckids.org + on_stop: delete review + auto_stop_in: 3 days + only: + - merge_requests + when: manual + script: + - cd deploy/overlays/review + - kustomize edit set image registry.edugit.org/teckids/team-pr/teckids.org:$CI_COMMIT_REF_NAME@$(cat ../../../DIGESTFILE) + - kustomize build | envsubst > output.yaml + - kubectl --kubeconfig=/tmp/kubeconfig apply -f output.yaml + +delete review: + extends: .deploy + script: delete_review + environment: + name: review/$CI_COMMIT_REF_SLUG + action: stop + before_script: + - echo $KUBECONFIG | base64 -d > /tmp/kubeconfig + - cd deploy/overlays/review + - kustomize build | envsubst > output.yaml + script: + - kubectl --kubeconfig=/tmp/kubeconfig delete -f output.yaml + when: manual + only: + - merge_requests diff --git a/deploy/overlays/review/kustomization.yaml b/deploy/overlays/review/kustomization.yaml index 89495c2995cde400f77ec8a56b0c9b9c10935277..5ee2add9785bfd592f8ff4f67e786ace712b1487 100644 --- a/deploy/overlays/review/kustomization.yaml +++ b/deploy/overlays/review/kustomization.yaml @@ -6,7 +6,7 @@ commonAnnotations: source-repository: https://edugit.org/Teckids/team-pr/teckids.org commonLabels: app: teckids-website - environment: production + environment: ${CI_COMMIT_REF_SLUG} namespace: teckids-website patches: - target: