-
Notifications
You must be signed in to change notification settings - Fork 56
187 lines (160 loc) · 6.48 KB
/
app-gateway.yml
File metadata and controls
187 lines (160 loc) · 6.48 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
name: App Gateway
on:
push:
branches:
- main
paths:
- "application/*"
- "application/shared-kernel/**"
- "application/AppGateway/**"
- ".github/workflows/app-gateway.yml"
- ".github/workflows/_deploy-container.yml"
- "!**.md"
pull_request:
paths:
- "application/*"
- "application/shared-kernel/**"
- "application/AppGateway/**"
- ".github/workflows/app-gateway.yml"
- ".github/workflows/_deploy-container.yml"
- "!**.md"
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.generate_version.outputs.version }}
deploy_staging: ${{ steps.determine_deployment.outputs.deploy_staging }}
deploy_production: ${{ steps.determine_deployment.outputs.deploy_production }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Generate Version
id: generate_version
run: |
# Zero-padded so versions sort lexicographically and clock-time is unambiguous (e.g. 0904, not 94)
VERSION=$(date +"%Y.%m.%d.%H%M")
echo "Generated version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Determine Deployment Conditions
id: determine_deployment
run: |
deploy_staging="${{ github.ref == 'refs/heads/main' && vars.STAGING_CLUSTER_ENABLED == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Deploy to Staging')) }}"
echo "deploy_staging=$deploy_staging" >> $GITHUB_OUTPUT
deploy_production="${{ github.ref == 'refs/heads/main' && vars.PRODUCTION_CLUSTER1_ENABLED == 'true' }}"
echo "deploy_production=$deploy_production" >> $GITHUB_OUTPUT
- name: Setup Node.js Environment
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install Node Modules
working-directory: application
run: npm ci
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v5
with:
global-json-file: application/global.json
- name: Restore .NET Tools
working-directory: application
run: dotnet tool restore
- name: Restore .NET Dependencies
working-directory: application
run: dotnet restore
- name: Build Backend Solution
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
working-directory: application
run: |
dotnet build PlatformPlatform.slnx --no-restore /p:Version=${{ steps.generate_version.outputs.version }} /p:DeploymentCommitHash=${{ github.event.pull_request.head.sha || github.sha }} /p:DeploymentGithubActionId=${{ github.run_id }}
- name: Publish Build
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
working-directory: application
run: |
dotnet publish ./AppGateway/AppGateway.csproj --no-restore --configuration Release --output ./AppGateway/publish /p:Version=${{ steps.generate_version.outputs.version }} /p:DeploymentCommitHash=${{ github.event.pull_request.head.sha || github.sha }} /p:DeploymentGithubActionId=${{ github.run_id }}
- name: Save Artifacts
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
uses: actions/upload-artifact@v7
with:
name: app-gateway
path: application/AppGateway/publish/**/*
code-style-and-linting:
name: Code Style and Linting
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Setup Node.js Environment
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install Node Modules
working-directory: application
run: npm ci
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v5
with:
global-json-file: application/global.json
- name: Restore .NET Tools
working-directory: application
run: dotnet tool restore
- name: Restore .NET Dependencies
working-directory: application
run: dotnet restore
- name: Build Backend Solution
working-directory: application
run: dotnet build PlatformPlatform.slnx --no-restore
- name: Run Code Linting
working-directory: developer-cli
run: |
dotnet run lint --backend | tee lint-output.log
if ! grep -q "No backend issues found!" lint-output.log; then
echo "Code linting issues found."
exit 1
fi
- name: Check for Code Formatting Issues
working-directory: developer-cli
run: |
dotnet run format --backend
# Check for any changes made by the code formatter
git diff --exit-code || {
echo "Formatting issues detected. Please run 'dotnet run format --backend' from /developer-cli folder locally and commit the formatted code."
exit 1
}
api-stage:
name: Staging
if: ${{ needs.build-and-test.outputs.deploy_staging == 'true' }}
needs: build-and-test
uses: ./.github/workflows/_deploy-container.yml
secrets: inherit
with:
image_name: app-gateway
version: ${{ needs.build-and-test.outputs.version }}
artifacts_name: app-gateway
artifacts_path: application/AppGateway/publish
docker_context: ./application
docker_file: ./AppGateway/Dockerfile
azure_environment: "stage"
cluster_location_acronym: ${{ vars.STAGING_CLUSTER_LOCATION_ACRONYM }}
service_principal_id: ${{ vars.STAGING_SERVICE_PRINCIPAL_ID }}
subscription_id: ${{ vars.STAGING_SUBSCRIPTION_ID }}
api-prod1:
name: Production
if: ${{ needs.build-and-test.outputs.deploy_production == 'true' }}
needs: [build-and-test, api-stage]
uses: ./.github/workflows/_deploy-container.yml
secrets: inherit
with:
image_name: app-gateway
version: ${{ needs.build-and-test.outputs.version }}
artifacts_name: app-gateway
artifacts_path: application/AppGateway/publish
docker_context: ./application
docker_file: ./AppGateway/Dockerfile
azure_environment: "prod"
cluster_location_acronym: ${{ vars.PRODUCTION_CLUSTER1_LOCATION_ACRONYM }}
service_principal_id: ${{ vars.PRODUCTION_SERVICE_PRINCIPAL_ID }}
subscription_id: ${{ vars.PRODUCTION_SUBSCRIPTION_ID }}