-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (130 loc) · 4.61 KB
/
backoffice_test.yml
File metadata and controls
161 lines (130 loc) · 4.61 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
name: BUILD BACKOFFICE TEST
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
KUBE_CONFIG_DATA__ST_TEST:
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 }}-test
tags: latest
add_git_labels: true
build_args: app_version=${{ steps.string.outputs.lowercase }}-test:latest,app_compilation_date=${{ steps.current-time.outputs.formattedTime }}
# restart:
# runs-on: self-hosted
# needs: [build]
# steps:
# - id: string
# uses: ASzc/change-string-case-action@v1
# with:
# string: ${{ inputs.repository_name }}
# - name: Restart service test
# uses: MyJetWallet/k8s-restart-pods@master
# env:
# KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA__ST_TEST }}
# NAMESPACE: spot-services
# IMAGE: ${{ steps.string.outputs.lowercase }}-test