-
Notifications
You must be signed in to change notification settings - Fork 3
174 lines (155 loc) · 6.47 KB
/
deploy-auth-service.yml
File metadata and controls
174 lines (155 loc) · 6.47 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
name: Deploy Auth Service
on:
pull_request:
branches:
- main
paths:
- 'infra/apps/auth-service/**'
- 'src/Biotrackr.Auth.Svc/**'
- '.github/workflows/deploy-auth-service.yml'
permissions:
contents: read
id-token: write
pull-requests: write
checks: write
env:
DOTNET_VERSION: 9.0.x
jobs:
env-setup:
name: Setup Environment
runs-on: ubuntu-latest
outputs:
dotnet-version: ${{ steps.set-output-defaults.outputs.dotnet-version }}
steps:
- name: set outputs with default values
id: set-output-defaults
run: |
echo "dotnet-version=${{ env.DOTNET_VERSION }}" >> "$GITHUB_OUTPUT"
run-unit-tests:
name: Run Unit Tests
needs: env-setup
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-unit-tests.yml@main
with:
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
working-directory: ./src/Biotrackr.Auth.Svc/Biotrackr.Auth.Svc.UnitTests
run-contract-tests:
name: Run Contract Tests
needs: env-setup
uses: willvelida/biotrackr/.github/workflows/template-dotnet-run-contract-tests.yml@main
with:
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
working-directory: ./src/Biotrackr.Auth.Svc/Biotrackr.Auth.Svc.IntegrationTests
test-filter: 'FullyQualifiedName~Contract'
run-e2e-tests:
name: Run E2E Tests
needs: [env-setup, run-contract-tests]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/Biotrackr.Auth.Svc/Biotrackr.Auth.Svc.IntegrationTests
steps:
- name: Checkout Repository code
uses: actions/checkout@v5
- name: Setup .NET ${{ needs.env-setup.outputs.dotnet-version }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ needs.env-setup.outputs.dotnet-version }}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --verbosity normal
- name: Run E2E tests
run: |
dotnet test \
--no-build \
--verbosity normal \
--filter "FullyQualifiedName~E2E" \
--logger "trx;LogFileName=e2e-test-results.trx" \
--results-directory ./TestResults
- name: Publish Test Results
uses: dorny/test-reporter@v2
if: always()
with:
name: E2E Test Results
path: ./src/Biotrackr.Auth.Svc/Biotrackr.Auth.Svc.IntegrationTests/TestResults/*.trx
reporter: dotnet-trx
fail-on-error: true
build-container-image-dev:
name: Build and Push Container Image
needs: [run-unit-tests, run-contract-tests, run-e2e-tests]
uses: willvelida/biotrackr/.github/workflows/template-acr-push-image.yml@main
with:
working-directory: ./src/Biotrackr.Auth.Svc
app-name: biotrackr-auth-svc
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resource-group-name: ${{ secrets.AZURE_RG_NAME_DEV }}
retrieve-container-image-dev:
name: Retrieve Container Image
needs: build-container-image-dev
runs-on: ubuntu-latest
outputs:
loginServer: ${{ steps.get-acr-server.outputs.loginServer }}
steps:
- name: Azure login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Get ACR server
id: get-acr-server
run: |
loginServer=$(az acr list --resource-group ${{ secrets.AZURE_RG_NAME_DEV }} --query "[0].loginServer" -o tsv)
echo "loginServer=$loginServer" > "$GITHUB_OUTPUT"
lint:
name: Run Bicep Linter
needs: retrieve-container-image-dev
uses: willvelida/biotrackr/.github/workflows/template-bicep-linter.yml@main
with:
template-file: './infra/apps/auth-service/main.bicep'
validate:
name: Validate Template
needs: [lint, retrieve-container-image-dev]
uses: willvelida/biotrackr/.github/workflows/template-bicep-validate.yml@main
with:
template-file: './infra/apps/auth-service/main.bicep'
parameters-file: ./infra/apps/auth-service/main.dev.bicepparam
parameters: '{"imageName": "${{ needs.retrieve-container-image-dev.outputs.loginServer }}/biotrackr-auth-svc:${{ github.sha }}"}'
scope: resourceGroup
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resource-group-name: ${{ secrets.AZURE_RG_NAME_DEV }}
preview:
name: Preview Changes
needs: [validate, retrieve-container-image-dev]
uses: willvelida/biotrackr/.github/workflows/template-bicep-whatif.yml@main
with:
scope: resourceGroup
template-file: './infra/apps/auth-service/main.bicep'
parameters-file: ./infra/apps/auth-service/main.dev.bicepparam
parameters: '{"imageName": "${{ needs.retrieve-container-image-dev.outputs.loginServer }}/biotrackr-auth-svc:${{ github.sha }}"}'
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resource-group-name: ${{ secrets.AZURE_RG_NAME_DEV }}
deploy-dev:
name: Deploy Template to Dev
needs: [preview, retrieve-container-image-dev]
uses: willvelida/biotrackr/.github/workflows/template-bicep-deploy.yml@main
with:
template-file: './infra/apps/auth-service/main.bicep'
parameters-file: ./infra/apps/auth-service/main.dev.bicepparam
parameters: '{"imageName": "${{ needs.retrieve-container-image-dev.outputs.loginServer }}/biotrackr-auth-svc:${{ github.sha }}"}'
scope: resourceGroup
environment: dev
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resource-group-name: ${{ secrets.AZURE_RG_NAME_DEV }}