-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (152 loc) · 4.85 KB
/
docker-build.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
name: WebIO build and publish
on:
push:
branches: [ "main", "beta" ]
pull_request:
branches: [ "main", "beta" ]
jobs:
build-frontend:
defaults:
run:
working-directory: ./webclient
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.17.0'
- name: Install dependencies
run: npm ci
- name: Swagger
run: npm run swagger
- name: put secrets in prod environment file
shell: bash
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |-
sed -i "s@#AZURE_CLIENT_ID#@${{ secrets.AZURE_CLIENT_ID }}@g" ./src/environments/environment.prod.ts
sed -i "s@#AZURE_TENANT_ID#@${{ secrets.AZURE_TENANT_ID }}@g" ./src/environments/environment.prod.ts
- name: Build
run: npm run build-prod
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: WebIO.Frontend
path: ./webclient/dist/metechno-io-db
build-and-test-backend:
defaults:
run:
working-directory: ./src/WebIO
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: getong/[email protected]
with:
elasticsearch version: '8.10.2'
host port: 9200
container port: 9200
host node port: 9300
node port: 9300
discovery type: 'single-node'
- uses: potatoqualitee/[email protected]
with:
install: sqlengine
version: 2022
sa-password: BVkMcwpF57vCCGQN7Pbr
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
publish-cli:
defaults:
run:
working-directory: ./src/WebIO
runs-on: ubuntu-latest
needs: build-and-test-backend
steps:
- uses: actions/checkout@v3
- name: Publish
run: dotnet publish -c Release -r win-x64 WebIO.Cli/WebIO.Cli.csproj
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: WebIO.Cli
path: ./src/WebIO/WebIO.Cli/bin/Release/net7.0/win-x64/publish
publish-api:
defaults:
run:
working-directory: ./src/WebIO
runs-on: ubuntu-latest
needs: build-and-test-backend
steps:
- uses: actions/checkout@v3
- name: Publish
run: dotnet publish -c Release WebIO.Api/WebIO.Api.csproj
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: WebIO.Api
path: ./src/WebIO/WebIO.Api/bin/Release/net7.0/publish
publish-docker:
runs-on: ubuntu-latest
needs:
- publish-api
- build-frontend
steps:
- uses: actions/checkout@v3
- name: Download API
uses: actions/download-artifact@v3
with:
name: WebIO.Api
path: build/app
- name: List API files
run: ls -la build/app
- name: Download Frontend
uses: actions/download-artifact@v3
with:
name: WebIO.Frontend
path: build/wwwroot
- name: List Frontend files
run: ls -la build/wwwroot
- name: Configure secrets
shell: bash
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_AUDIENCE: ${{ secrets.AZURE_AUDIENCE }}
AZURE_INSTANCE: ${{ env.AZURE_INSTANCE }}
run: |
sed -i "s@#AZURE_CLIENT_ID#@${{ secrets.AZURE_CLIENT_ID }}@g" ./build/app/appsettings.Production.json
sed -i "s@#AZURE_TENANT_ID#@${{ secrets.AZURE_TENANT_ID }}@g" ./build/app/appsettings.Production.json
sed -i "s@#AZURE_AUDIENCE#@${{ secrets.AZURE_AUDIENCE }}@g" ./build/app/appsettings.Production.json
sed -i "s@#AZURE_INSTANCE#@https://login.microsoftonline.com/@g" ./build/app/appsettings.Production.json
- name: Docker build
run: |
cd build
docker build -t webio:latest -t webio:${{ github.run_id }} .
docker save webio:latest --output ./webio-latest.tar
docker save webio:${{ github.run_id }} --output ./webio-${{ github.run_id }}.tar
- name: Upload latest
uses: actions/upload-artifact@v3
with:
name: WebIO.Docker-latest
path: ./build/webio-latest.tar
- name: Upload run-id version
uses: actions/upload-artifact@v3
with:
name: WebIO.Docker-${{ github.run_id }}
path: ./build/webio-${{ github.run_id }}.tar