-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (165 loc) · 5.42 KB
/
Copy pathdeployment.yml
File metadata and controls
194 lines (165 loc) · 5.42 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
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Deployment Workflow
on:
push:
branches: [ "main", "dev"]
pull_request:
branches: [ "main" ]
types:
- opened
- closed
- edited
env:
ASPNETCORE_ENVIRONMENT: Development
JwtTokenOptions__RefreshTokenExpiryMinutes: 10080
JwtTokenOptions__Issuer: eCommerceApi
JwtTokenOptions__ExpiryMinutes: 60
JwtTokenOptions__Audience: eCommerceClient
Serilog__Using__0: Serilog.Sinks.MSSqlServer
Serilog__Using__1: Serilog.Sinks.Seq
Serilog__Using__2: Serilog.Sinks.Debug
Serilog__Enrich__0: FromLogContext
Serilog__Enrich__1: WithThreadId
Serilog__Enrich__2: WithMachineName
Serilog__Properties__Application: ECommerceApi
Serilog__WriteTo__0__Name: MSSqlServer
Serilog__WriteTo__0__Args__tableName: Logs
Serilog__WriteTo__0__Args__autoCreateSqlTable: true
Serilog__WriteTo__0__Args__batchPostingLimit: 200
Serilog__WriteTo__0__Args__period: 00:00:10
Serilog__WriteTo__1__Name: Seq
Serilog__WriteTo__1__Args__serverUrl: http://host.docker.internal:5341
Serilog__WriteTo__2__Name: Debug
Serilog__MinimumLevel__Default: Debug
Serilog__MinimumLevel__Override__Microsoft.AspNetCore: Debug
Serilog__MinimumLevel__Override__Microsoft.EntityFrameworkCore: Debug
# secrets
ASPNETCORE_URLS: ${{ secrets.ASPNETCORE_URLS }}
JwtTokenOptions__SecretKey: ${{ secrets.JwtTokenOptions__SecretKey }}
Authentication__Google__ClientSecret: ${{ secrets.Authentication__Google__ClientSecret }}
Authentication__Google__ClientId: ${{ secrets.Authentication__Google__ClientId }}
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
SQL_PORT: ${{ vars.SQL_PORT }}
SQL_PASSWORD: ${{ vars.SQL_PASSWORD }}
API_PORT: ${{ vars.API_PORT }}
jobs:
build-test:
# continue-on-error: true
strategy:
matrix:
dotnet-version: ["8.0.x", "9.0.x", "10.0.x"]
operating-system: ["ubuntu-latest", "windows-latest"]
exclude:
- operating-system: "windows-latest"
runs-on: ${{ matrix.operating-system }}
container:
image: mcr.microsoft.com/dotnet/sdk:10.0
environment: staging
services:
sql:
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: ${{ secrets.SQL_PASSWORD }}
volumes:
- sql-data:/var/opt/mssql
redis:
image: redis:7
ports:
- 6379:6379
volumes:
- redis-data:/data
env:
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
entrypoint: /bin/sh
command: -c 'exec redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes'
steps:
- name: Get Code
uses: actions/checkout@v4
- name: Get & Cache Dependencies
id: deps
uses: ./.github/actions/cache-deps
with:
cache-disable: 'true'
- name: Build
run: dotnet build ./eCommerceSolution.slnx -c Release --no-restore
- name: Test
run: dotnet test ./eCommerceSolution.slnx -c Release --no-build --verbosity normal
- name: Job report
run: echo "cache disabled? ${{ steps.deps.outputs.cache-used }}"
build-publish:
strategy:
matrix:
dotnet-version: ["8.0.x", "9.0.x", "10.0.x"]
operating-system: ["ubuntu-latest", "windows-latest"]
exclude:
- operating-system: "windows-latest"
runs-on: ${{ matrix.operating-system }}
container:
image: mcr.microsoft.com/dotnet/sdk:10.0
services:
sql:
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: ${{ secrets.SQL_PASSWORD }}
volumes:
- sql-data:/var/opt/mssql
redis:
image: redis:7
ports:
- 3000:6379
volumes:
- redis-data:/data
env:
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
entrypoint: /bin/sh
command: -c 'exec redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes'
environment: production
outputs:
random-number: ${{ steps.publish.outputs.random-num }}
steps:
- name: Get Code
uses: actions/checkout@v4
- name: Get & Cache Dependencies
id: deps
uses: ./.github/actions/cache-deps
- name: Build for publish
id: publish
run: |
dotnet publish ./src/eCommerce.Api -c Release -o ./publish
echo "random-num=10" >> "$GITHUB_OUTPUT"
- name: Uploading Artifacts
uses: actions/upload-artifact@v4
with:
name: publish-artifacts
path: ./publish
- name: Job report
run: echo "cache disabled? ${{ steps.deps.outputs.cache-used }}"
deploy:
needs: [build-test, build-publish]
uses: ./.github/workflows/reusable-deploy.yml
with:
artifact-name: "./publish"
deploy-result:
needs: deploy
runs-on: ubuntu-latest
environment: production
steps:
- name: output deploy result
run: echo "Deployment is ${{ needs.deploy.outputs.deploy-result }}"
workflow-report:
needs: deploy
if: failure()
runs-on: ubuntu-latest
steps:
- name: Output information
run: |
echo "something went wrong"
echo "${{ toJson(github) }}"