-
Notifications
You must be signed in to change notification settings - Fork 30
160 lines (134 loc) · 4.61 KB
/
app-gateway.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
149
150
151
152
153
154
155
156
157
158
159
160
name: App Gateway - Build and Deploy
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 }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate version
id: generate_version
run: |
# Strip leading 0s of Hours and Minutes after midnight
MINUTE=$(printf "%s" $(date +"%-H%M") | sed 's/^0*//')
VERSION=$(date +"%Y.%-m.%-d.")$MINUTE
echo "Generated version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node modules
working-directory: application
run: npm ci
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- 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.sln --no-restore /p:Version=${{ steps.generate_version.outputs.version }}
- name: Publish build
if: github.ref == 'refs/heads/main'
working-directory: application
run: |
dotnet publish ./AppGateway/AppGateway.csproj --no-restore --configuration Release --output ./AppGateway/publish /p:Version=${{ steps.generate_version.outputs.version }}
- name: Save artifacts
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: app-gateway
path: application/AppGateway/publish/**/*
code-style-and-linting:
name: Code Style and Linting
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node modules
working-directory: application
run: npm ci
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- 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.sln --no-restore
- name: Run code inspections
working-directory: application
run: |
dotnet jb inspectcode PlatformPlatform.sln --no-build --output=result.json --severity=SUGGESTION
# Check if there are any issues. <Issues /> indicates no issues found.
if ! grep -q '\"results\": \[\],' result.json; then
cat result.json
echo "Code inspection issues found."
exit 1
fi
- name: Check for code formatting issues
working-directory: application
run: |
dotnet jb cleanupcode PlatformPlatform.sln --no-build --profile=".NET only"
# Check for any changes made by the code formatter
git diff --exit-code || {
echo "Formatting issues detected. Please run 'dotnet jb cleanupcode PlatformPlatform.sln --profile=\".NET only\"' locally and commit the formatted code."
exit 1
}
deploy:
name: Deploy
if: github.ref == 'refs/heads/main'
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