-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgitlab-ci.yml
95 lines (86 loc) · 2.24 KB
/
gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#cache:
# key: "terraform"
# paths:
# - terraform/.terraform/
variables:
TF_STATE_NAME: kubernetes
stages:
- validate
- build
- deploy
# ----------------------------------------------------------------------
# TERRAFORM
# ----------------------------------------------------------------------
terraform_fmt:
image: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
stage: validate
rules:
- changes:
- .gitlab-ci.yml
- terraform/*
- terraform/**/*
allow_failure: true
script:
- cd terraform
- gitlab-terraform init
- gitlab-terraform fmt -check -recursive
terraform_validate:
image: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
stage: validate
rules:
- changes:
- .gitlab-ci.yml
- terraform/*
- terraform/**/*
script:
- cd terraform
- gitlab-terraform init
- gitlab-terraform validate
terraform_build:
image: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
stage: build
resource_group: ${CI_PROJECT_NAME}
rules:
- changes:
- .gitlab-ci.yml
- terraform/*
- terraform/**/*
script:
- cd terraform
- gitlab-terraform init
- gitlab-terraform plan
- gitlab-terraform plan-json
artifacts:
paths:
- terraform/plan.cache
reports:
terraform: terraform/plan.json
terraform_deploy:
image: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
stage: deploy
resource_group: ${CI_PROJECT_NAME}
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
changes:
- .gitlab-ci.yml
- terraform/*
- terraform/**/*
script:
- cd terraform
- gitlab-terraform init
- gitlab-terraform apply
# ----------------------------------------------------------------------
# CLUSTER APPS
# ----------------------------------------------------------------------
argocd_deploy:
image: bitnami/kubectl:latest
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
changes:
- .gitlab-ci.yml
- argocd/*
script:
- if [ -d argocd ]; then
kubectl --token ${TF_VAR_rancher_token} --server "https://gonzo-rancher.ncsa.illinois.edu/k8s/clusters/${TF_VAR_argocd_kube_id}" apply -f ./argocd;
fi