diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1cc693399bb3d30778dd076a4554a17429d0b5ec..ae294092c4d64c72f554eaca060b61ea7596ce02 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,9 @@ +# docs: https://docs.gitlab.com/ee/user/infrastructure/iac/terraform_state.html#get-started-using-gitlab-ci + image: busybox:latest -# docs: https://docs.gitlab.com/ee/user/infrastructure/iac/terraform_state.html#get-started-using-gitlab-ci -terraform-elastic: - stage: deploy +check-elastic: + stage: test tags: - docker image: @@ -18,10 +19,8 @@ terraform-elastic: gitlab-terraform validate gitlab-terraform fmt -check gitlab-terraform plan -# gitlab-terraform apply -auto-approve -# gitlab-terraform destroy -auto-approve -terraform-magento: +check-magento: stage: deploy tags: - docker @@ -41,14 +40,51 @@ terraform-magento: gitlab-terraform validate gitlab-terraform fmt -check gitlab-terraform plan -# gitlab-terraform apply -auto-approve -# gitlab-terraform destroy -auto-approve + +apply-elastic: + stage: deploy + needs: + - check-elastic + tags: + - docker + image: + name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest + entrypoint: [""] + variables: + TF_ROOT: ${CI_PROJECT_DIR}/manifests/elastic + TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/elastic + TF_VAR_ec_apikey: $EC_API_KEY + script: |- + cd $TF_ROOT + gitlab-terraform init + gitlab-terraform apply -auto-approve + +apply-magento: + stage: deploy + needs: + - check-magento + tags: + - docker + image: + name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest + entrypoint: [""] + variables: + TF_ROOT: ${CI_PROJECT_DIR}/manifests/magento + TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/magento + TF_VAR_ec_apikey: $EC_API_KEY + TF_VAR_project_id: $GCP_PROJECT_ID + GCP_SA_GITLAB: $GCP_SA_GITLAB + script: |- + cd $TF_ROOT + echo $GCP_SA_GITLAB > gcp-sa.json + gitlab-terraform init + gitlab-terraform apply -auto-approve gcloud-psc: stage: deploy needs: - - terraform-elastic - - terraform-magento + - apply-elastic + - apply-magento tags: - docker image: