-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (194 loc) · 8.68 KB
/
pr-verify.yml
File metadata and controls
208 lines (194 loc) · 8.68 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: PR Verify
# Label-based workflow control:
# - Always run Terraform plan against Development (skips drafts)
# - 'deploy-dev': Runs Terraform plan+apply and deploys database + apps to Development (skips drafts/dependabot)
# - 'run-prd-plan': Runs Terraform plan against Production (skips drafts/dependabot)
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
permissions: {}
jobs:
build-and-test:
permissions:
contents: read
id-token: write
pull-requests: write
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: frasermolyneux/actions/dotnet-ci@dotnet-ci/v1.4
with:
dotnet-version: |
9.0.x
10.0.x
src-folder: "src"
skip-nuget-artifact-upload: "true"
- uses: frasermolyneux/actions/dotnet-web-ci@dotnet-web-ci/v1.4
with:
dotnet-project: "XtremeIdiots.Portal.Repository.Api.V1"
dotnet-version: |
9.0.x
10.0.x
src-folder: "src"
skip-nuget-artifact-upload: "true"
- uses: frasermolyneux/actions/dotnet-web-ci@dotnet-web-ci/v1.4
with:
dotnet-project: "XtremeIdiots.Portal.Repository.Api.V2"
dotnet-version: |
9.0.x
10.0.x
src-folder: "src"
skip-nuget-artifact-upload: "true"
terraform-plan-dev:
permissions:
contents: read
id-token: write
pull-requests: write
if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'deploy-dev')
needs: build-and-test
environment: Development
runs-on: ubuntu-latest
concurrency:
group: ${{ github.repository }}-dev
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
steps:
- uses: frasermolyneux/actions/terraform-plan@terraform-plan/v1.4
with:
terraform-folder: "terraform"
terraform-var-file: "tfvars/dev.tfvars"
terraform-backend-file: "backends/dev.backend.hcl"
AZURE_CLIENT_ID: ${{ env.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ env.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ env.AZURE_SUBSCRIPTION_ID }}
terraform-plan-and-apply-dev:
permissions:
contents: read
id-token: write
pull-requests: write
if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'deploy-dev')
needs: build-and-test
environment: Development
runs-on: ubuntu-latest
concurrency:
group: ${{ github.repository }}-dev
steps:
- uses: frasermolyneux/actions/terraform-plan-and-apply@terraform-plan-and-apply/v1.4
with:
terraform-folder: "terraform"
terraform-var-file: "tfvars/dev.tfvars"
terraform-backend-file: "backends/dev.backend.hcl"
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- id: terraform-output
shell: bash
run: |
cd terraform
echo "web_app_name_v1=$(terraform output -raw web_app_name_v1)" >> $GITHUB_OUTPUT
echo "web_app_resource_group_v1=$(terraform output -raw web_app_resource_group_v1)" >> $GITHUB_OUTPUT
echo "web_app_name_v2=$(terraform output -raw web_app_name_v2)" >> $GITHUB_OUTPUT
echo "web_app_resource_group_v2=$(terraform output -raw web_app_resource_group_v2)" >> $GITHUB_OUTPUT
echo "sql_server_fqdn=$(terraform output -raw sql_server_fqdn)" >> $GITHUB_OUTPUT
echo "sql_database_name=$(terraform output -raw sql_database_name)" >> $GITHUB_OUTPUT
env:
ARM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
ARM_USE_AZUREAD: true
ARM_USE_OIDC: true
outputs:
web_app_name_v1: ${{ steps.terraform-output.outputs.web_app_name_v1 }}
web_app_resource_group_v1: ${{ steps.terraform-output.outputs.web_app_resource_group_v1 }}
web_app_name_v2: ${{ steps.terraform-output.outputs.web_app_name_v2 }}
web_app_resource_group_v2: ${{ steps.terraform-output.outputs.web_app_resource_group_v2 }}
sql_server_fqdn: ${{ steps.terraform-output.outputs.sql_server_fqdn }}
sql_database_name: ${{ steps.terraform-output.outputs.sql_database_name }}
deploy-sql-database-dev:
permissions:
contents: read
id-token: write
pull-requests: write
if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'deploy-dev')
environment: Development
needs: terraform-plan-and-apply-dev
runs-on: ubuntu-latest
concurrency:
group: ${{ github.repository }}-dev
steps:
- uses: frasermolyneux/actions/deploy-sql-database@deploy-sql-database/v1.2
with:
sql-args: /Variables:env=dev /Variables:instance=01
sql-server-fqdn: ${{ needs.terraform-plan-and-apply-dev.outputs.sql_server_fqdn }}
sql-database-name: ${{ needs.terraform-plan-and-apply-dev.outputs.sql_database_name }}
project-folder: "src/XtremeIdiots.Portal.Repository.Database"
project-file: "XtremeIdiots.Portal.Repository.Database.sqlproj"
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
app-service-deploy-v1-dev:
permissions:
contents: read
id-token: write
pull-requests: write
if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'deploy-dev')
environment: Development
needs: [build-and-test, terraform-plan-and-apply-dev, deploy-sql-database-dev]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.repository }}-dev
steps:
- uses: frasermolyneux/actions/deploy-app-service@deploy-app-service/v1.2
with:
web-artifact-name: "XtremeIdiots.Portal.Repository.Api.V1"
web-app-name: ${{ needs.terraform-plan-and-apply-dev.outputs.web_app_name_v1 }}
resource-group-name: ${{ needs.terraform-plan-and-apply-dev.outputs.web_app_resource_group_v1 }}
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
app-service-deploy-v2-dev:
permissions:
contents: read
id-token: write
pull-requests: write
if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'deploy-dev')
environment: Development
needs: [build-and-test, terraform-plan-and-apply-dev, deploy-sql-database-dev]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.repository }}-dev
steps:
- uses: frasermolyneux/actions/deploy-app-service@deploy-app-service/v1.2
with:
web-artifact-name: "XtremeIdiots.Portal.Repository.Api.V2"
web-app-name: ${{ needs.terraform-plan-and-apply-dev.outputs.web_app_name_v2 }}
resource-group-name: ${{ needs.terraform-plan-and-apply-dev.outputs.web_app_resource_group_v2 }}
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
terraform-plan-prd:
permissions:
contents: read
id-token: write
pull-requests: write
if: github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'run-prd-plan')
needs: build-and-test
environment: Production
runs-on: ubuntu-latest
concurrency:
group: ${{ github.repository }}-prd
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
steps:
- uses: frasermolyneux/actions/terraform-plan@terraform-plan/v1.4
with:
terraform-folder: "terraform"
terraform-var-file: "tfvars/prd.tfvars"
terraform-backend-file: "backends/prd.backend.hcl"
AZURE_CLIENT_ID: ${{ env.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ env.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ env.AZURE_SUBSCRIPTION_ID }}