-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (159 loc) · 5.91 KB
/
backoffice.yml
File metadata and controls
194 lines (159 loc) · 5.91 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
194
name: BUILD BACKOFFICE UAT
on:
workflow_call:
inputs:
repository_name:
required: true
type: string
repository_type:
required: true
type: string
release_version:
required: true
type: string
secrets:
ST_DOCKER_USER:
required: true
ST_DOCKER_PASSWORD:
required: true
AZURE_CONTAINER_REGISTRY:
required: true
UAT_GIT_TOKEN:
required: true
NUGET_AUTH_TOKEN:
required: true
jobs:
build:
runs-on: self-hosted
env:
DOTNET_INSTALL_DIR: "/home/monfex"
steps:
- uses: actions/checkout@v3
- name: Update TargetFramework and Docker base image
run: |
python3 - << 'PY'
from pathlib import Path
ROOT = Path(".").resolve()
TF_OLD = "<TargetFramework>net8.0</TargetFramework>"
TF_NEW = "<TargetFramework>net10.0</TargetFramework>"
DOCKER_OLD = "mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim"
DOCKER_NEW = "mcr.microsoft.com/dotnet/aspnet:10.0-noble"
SKIP_DIRS = {'.git', '.github', 'bin', 'obj', '.idea', '.vs'}
def should_skip(path: Path) -> bool:
return any(part in SKIP_DIRS for part in path.parts)
def update_file(path: Path, old: str, new: str) -> bool:
try:
text = path.read_text(encoding="utf-8")
except UnicodeDecodeError:
return False
if old not in text:
return False
new_text = text.replace(old, new)
if new_text == text:
return False
path.write_text(new_text, encoding="utf-8")
print(f"updated: {path}")
return True
tf_changed = 0
docker_changed = 0
for pattern in ("*.csproj", "*.fsproj", "*.vbproj"):
for path in ROOT.rglob(pattern):
if should_skip(path):
continue
if update_file(path, TF_OLD, TF_NEW):
tf_changed += 1
for path in ROOT.rglob("Dockerfile*"):
if should_skip(path):
continue
if update_file(path, DOCKER_OLD, DOCKER_NEW):
docker_changed += 1
print(f"Summary: project files updated = {tf_changed}, Dockerfiles updated = {docker_changed}")
PY
- name: Set .NET root
run: echo "DOTNET_ROOT=/home/monfex" >> $GITHUB_ENV
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '10.0.x'
source-url: https://nuget.pkg.github.com/myjetwallet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
- name: Get current time
uses: MyJetTools/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DD HH:mm:ss
utcOffset: "+00:00"
- name: list nugets
run: dotnet nuget list source
- name: Restore
run: dotnet restore
continue-on-error: true
- name: Build microservice
run: dotnet build --no-restore --configuration Release /p:AssemblyVersion=${{ inputs.release_version }}
- name: Test microservice
run: dotnet test --no-build --configuration Release
- name: Publish Service
run: dotnet publish ./Backoffice/Backoffice.csproj --configuration Release /p:AssemblyVersion=${{ inputs.release_version }} --output ./publish-api
- name: Check Service dir
run: ls ./publish-api
- id: string
uses: ASzc/change-string-case-action@v1
with:
string: ${{ inputs.repository_name }}
- name: Publish image azure
uses: docker/build-push-action@v1
with:
username: ${{ secrets.ST_DOCKER_USER }}
password: ${{ secrets.ST_DOCKER_PASSWORD }}
path: ./publish-api
registry: ${{ secrets.AZURE_CONTAINER_REGISTRY }}
repository: spot/${{ steps.string.outputs.lowercase }}
tag_with_ref: true
build_args: app_version=${{ steps.string.outputs.lowercase }}:{{ inputs.release_version }},app_compilation_date=${{ steps.current-time.outputs.formattedTime }}
k8s-deploy:
needs: [build]
runs-on: self-hosted
steps:
- id: string
uses: ASzc/change-string-case-action@v1
with:
string: ${{ inputs.repository_name }}
- name: get uat k8s yamls
uses: actions/checkout@v2
with:
repository: MyJetWallet/kubernates-infrastructure
ref: uat
token: ${{ secrets.UAT_GIT_TOKEN }}
- run: |
pattern=${{ steps.string.outputs.lowercase }}:.*$
imagename=${{ steps.string.outputs.lowercase }}:${{ inputs.release_version }}
reg=$"s/${pattern}/${imagename}/g"
echo $reg
find . -type f -name "*.*ml" -exec sed -i -r $reg {} \;
git config user.name github-actions
git config user.email github-actions@github.com
if git status | grep -q modified; then git commit -a -m "Update version of service myjetwallet.${{ steps.string.outputs.lowercase }}" && git push; fi
docker-deploy:
needs: [build, k8s-deploy]
runs-on: self-hosted
steps:
- id: string
uses: ASzc/change-string-case-action@v1
with:
string: ${{ inputs.repository_name }}
- name: get uat docker yamls
uses: actions/checkout@v2
with:
repository: MyJetWallet/docker-infrastructure
ref: uat
token: ${{ secrets.UAT_GIT_TOKEN }}
- run: |
pattern=${{ steps.string.outputs.lowercase }}:.*$
imagename=${{ steps.string.outputs.lowercase }}:${{ inputs.release_version }}
reg=$"s/${pattern}/${imagename}/g"
echo $reg
find . -type f -name "*.*ml" -exec sed -i -r $reg {} \;
git config user.name github-actions
git config user.email github-actions@github.com
if git status | grep -q modified; then git commit -a -m "Update version of service myjetwallet.${{ steps.string.outputs.lowercase }}" && git push; fi