-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
106 lines (98 loc) · 2.04 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
96
97
98
99
100
101
102
103
104
105
106
.dotnet:
image: microsoft/dotnet:latest
before_script:
- cd HelloWorld.App
- dotnet restore --packages ./.nuget/
only:
changes:
- HelloWorld.App/**/*
- .gitlab-ci.yml
refs:
- merge_requests
- master
- web
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- HelloWorld.App/.nuget/
.terraform:
variables:
TERRAFORM_WORKSPACE: 'dev'
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
before_script:
- cd terraform
- terraform init
- terraform workspace select $TERRAFORM_WORKSPACE || terraform workspace new $TERRAFORM_WORKSPACE
cache:
key: terraform
paths:
- terraform/.terraform
only:
changes:
- terraform/**/*
- .gitlab-ci.yml
refs:
- master
- web
stages:
- build
- test
- package
- terraform_plan
- terraform_apply
build:
extends: .dotnet
stage: build
script:
- dotnet build --no-restore
test:
extends: .dotnet
stage: test
script:
- dotnet test --no-restore
package:
extends: .dotnet
stage: package
script:
- dotnet publish HelloWorld.App -c Release -o ../artifacts/HelloWorld.App --no-restore
artifacts:
name: "HelloWorld.App"
paths:
- HelloWorld.App/artifacts/HelloWorld.App
expire_in: 1 year
only:
refs:
- master
- web
terraform_validate:
extends: .terraform
stage: build
script:
- terraform validate
only:
refs:
- master
- merge_requests
- web
terraform_plan:
extends: .terraform
stage: terraform_plan
script:
- terraform plan -out=plan.data
artifacts:
name: "terraform_plan"
paths:
- terraform/plan.data
expire_in: 1 year
terraform_apply:
extends: .terraform
stage: terraform_apply
script:
- terraform apply plan.data
environment:
name: $TERRAFORM_WORKSPACE
when: manual