Commit 8a95f377 authored by mohoff's avatar mohoff

feat: add job that deploys latest master to review cluster

parent b45d2e71
Pipeline #23535 passed with stages
in 20 seconds
......@@ -140,3 +140,66 @@ stop_review:
environment:
name: $CI_COMMIT_REF_SLUG
action: stop
master_deploy_to_review:
stage: post-deploy
image: registry.brickblock.sh/devops/deploy
variables:
BBK_RUNTIME_ENVIRONMENT: review
GOOGLE_PROJECT: bbk-review
NODE_ENV: review
JQ_TRANSFORMATION: '
[ { host: "${CI_PROJECT_PATH_SLUG}.master.${REVIEW_DOMAIN}", path: "/" } ]
| { "ingresses": . }'
JQ_FIRST_INGRESS: '.ingresses[0] | (.host + .path)'
DEPLOYMENT_NAME: master-${CI_PROJECT_PATH_SLUG}
extends:
- .except-ci-release
- .use-gcloud
- .skip-artifacts
only:
- master
interruptible: true
retry: 1
script:
- jq "${JQ_TRANSFORMATION}" brickblock.json > terraform.tfvars.json
- export FIRST_INGRESS=$(jq "${JQ_FIRST_INGRESS}" terraform.tfvars.json)
- |
cat << EOF > main.tf
terraform {
backend "gcs" {
bucket = "bbk-review-terraform-deploys"
}
}
module "bbk_deploy" {
source = "git::https://git.brickblock.sh/devops/infrastructure/k8s-cluster-deploy.git"
app = {
name = "${DEPLOYMENT_NAME}"
group = "${NAMESPACE_SLUG}"
image = "${CI_REGISTRY_IMAGE}"
image_tag = "latest"
runtime_environment = "${BBK_RUNTIME_ENVIRONMENT}"
replicas = "${REPLICAS}"
port = "${APP_PORT}"
}
db = {
enabled = ${HAS_DB}
should_delete = ${DB_SHOULD_DELETE}
}
ingresses = var.ingresses
}
variable "ingresses" {}
EOF
- kubectl create namespace ${NAMESPACE_SLUG} --dry-run -o yaml | kubectl apply -f -
- terraform init
- terraform workspace new ${DEPLOYMENT_NAME} || true
- terraform workspace select ${DEPLOYMENT_NAME}
- terraform plan -input=false
- terraform apply -auto-approve
- kubectl wait --for=condition=available --timeout=3m deployment/${DEPLOYMENT_NAME} -n ${NAMESPACE_SLUG}
- printf "\n\n ✅ Successfully deployed to https://${CI_PROJECT_PATH_SLUG}.master.${REVIEW_DOMAIN}\n\n"
environment:
name: review-master-deployments
url: https://${CI_PROJECT_PATH_SLUG}.master.${REVIEW_DOMAIN}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment