Skip to content

Commit

Permalink
Merge pull request #48 from code0-tech/separate-envs
Browse files Browse the repository at this point in the history
Update pipeline to support separated environments
  • Loading branch information
Taucher2003 authored Jul 11, 2024
2 parents 2ee7274 + 9615fa6 commit aeff8ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
30 changes: 19 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ default:
before_script:
- cd $TF_ROOT

tf-plan:main:
.tf-plan:
extends:
- .tf
stage: terraform-plan
resource_group: tf/main
resource_group: tf/$TF_STATE_NAME
script:
- gitlab-terraform plan | tee output
- gitlab-terraform plan-json
Expand All @@ -29,28 +29,36 @@ tf-plan:main:
- $TF_ROOT/plan.cache
reports:
terraform: $TF_ROOT/plan.json
variables:
TF_STATE_NAME: main
TF_ROOT: '.'

tf-apply:main:
.tf-apply:
extends:
- .tf
stage: terraform-apply
resource_group: tf/main
needs:
- tf-plan:main
resource_group: tf/$TF_STATE_NAME
script:
- gitlab-terraform apply | tee output
- |
echo -e "\e[0Ksection_start:`date +%s`:glpa_summary\r\e[0KHeader of the summary"
grep "Apply complete!" output | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g"
echo -e "\e[0Ksection_end:`date +%s`:glpa_summary\r\e[0K"
environment:
name: main
name: $TF_STATE_NAME
deployment_tier: production
variables: !reference ["tf-plan:main", variables]
rules:
- if: $C0_GH_REF == "refs/heads/main"
when: delayed
start_in: 2 min

tf-plan:main:
extends:
- .tf-plan
variables:
TF_STATE_NAME: main
TF_ROOT: 'envs/main'

tf-apply:main:
extends:
- .tf-apply
needs:
- tf-plan:main
variables: !reference ["tf-plan:main", variables]
4 changes: 2 additions & 2 deletions main.tf → envs/main/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ provider "github" {
}

module "domain" {
source = "./system/domain"
source = "../../system/domain"
cloudflare_account_id = var.cloudflare_account_id
cloudflare_api_token = var.cloudflare_api_token
}

module "github" {
source = "./system/github"
source = "../../system/github"
}
File renamed without changes.

0 comments on commit aeff8ac

Please sign in to comment.