-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (119 loc) · 4.99 KB
/
release-to-production.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
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
name: Release to Production
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: "0 3 * * 4" # Every Thursday at 3am
permissions:
id-token: write # This is required for Az CLI Login
contents: read # This is required for actions/checkout
concurrency: # This is required to prevent multiple runs of the same workflow from running at the same time.
group: ${{ github.workflow }}
jobs:
dotnet-func-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/dotnet-func-ci@main
with:
dotnet-project: "event-ingest-func"
dotnet-version: 8.0.x
src-folder: "src"
majorMinorVersion: "1.1"
publish-nuget-packages:
environment: NuGet
runs-on: ubuntu-latest
needs: [dotnet-func-ci]
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/publish-nuget-packages@main
with:
artifact-name: "nuget-packages"
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
terraform-plan-and-apply-dev:
environment: Development
runs-on: ubuntu-latest
concurrency: # This is required to prevent multiple GitHub Actions invocations against stateful resources. e.g. Terraform state file / Database / Deployed Apps
group: ${{ github.repository }}-dev
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/terraform-plan-and-apply@main
with:
terraform-folder: "terraform"
terraform-var-file: "tfvars/dev.tfvars"
terraform-backend-file: "backends/dev.backend.hcl"
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- id: terraform-output
shell: bash
run: |
cd terraform
echo "function_app_name=$(terraform output -raw function_app_name)" >> $GITHUB_OUTPUT
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_USE_OIDC: true
outputs:
function_app_name: ${{ steps.terraform-output.outputs.function_app_name }}
function-app-deploy-dev:
environment: Development
runs-on: ubuntu-latest
needs: [dotnet-func-ci, terraform-plan-and-apply-dev]
concurrency: # This is required to prevent multiple GitHub Actions invocations against stateful resources. e.g. Terraform state file / Database / Deployed Apps
group: ${{ github.repository }}-dev
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/deploy-function-app@main
with:
function-app-artifact-name: "event-ingest-func"
function-app-name: ${{ needs.terraform-plan-and-apply-dev.outputs.function_app_name }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
terraform-plan-and-apply-prd:
environment: Production
runs-on: ubuntu-latest
needs: [function-app-deploy-dev]
concurrency: # This is required to prevent multiple GitHub Actions invocations against stateful resources. e.g. Terraform state file / Database / Deployed Apps
group: ${{ github.repository }}-prd
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/terraform-plan-and-apply@main
with:
terraform-folder: "terraform"
terraform-var-file: "tfvars/prd.tfvars"
terraform-backend-file: "backends/prd.backend.hcl"
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- id: terraform-output
shell: bash
run: |
cd terraform
echo "function_app_name=$(terraform output -raw function_app_name)" >> $GITHUB_OUTPUT
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_USE_OIDC: true
outputs:
function_app_name: ${{ steps.terraform-output.outputs.function_app_name }}
function-app-deploy-prd:
environment: Production
runs-on: ubuntu-latest
needs: [dotnet-func-ci, terraform-plan-and-apply-prd]
concurrency: # This is required to prevent multiple GitHub Actions invocations against stateful resources. e.g. Terraform state file / Database / Deployed Apps
group: ${{ github.repository }}-prd
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/deploy-function-app@main
with:
function-app-artifact-name: "event-ingest-func"
function-app-name: ${{ needs.terraform-plan-and-apply-prd.outputs.function_app_name }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}