-
Notifications
You must be signed in to change notification settings - Fork 3
275 lines (239 loc) · 9.31 KB
/
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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# Copyright 2022 MONAI Consortium
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build & Release
on:
pull_request:
push:
workflow_dispatch:
env:
BUILD_CONFIG: "Release"
SOLUTION: "Monai.Deploy.WorkflowManager.sln"
jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: WorkflowManager.Dockerfile
image: ghcr.io/project-monai/monai-deploy-workflow-manager
- dockerfile: TaskManager.Dockerfile
image: ghcr.io/project-monai/monai-deploy-task-manager
- dockerfile: CallbackApp.Dockerfile
image: ghcr.io/project-monai/monai-deploy-task-manager-callback
outputs:
semVer: ${{ steps.gitversion.outputs.semVer }}
majorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}
env:
REGISTRY: ghcr.io
permissions:
packages: write
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
run: dotnet tool install --global GitVersion.Tool
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
updateAssemblyInfo: true
updateAssemblyInfoFilename: src/AssemblyInfo.cs
configFilePath: .github/.gitversion.yml
- name: Print Assembly File
run: cat src/AssemblyInfo.cs
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=${{ steps.gitversion.outputs.semVer }}
- name: Build and Push Container Image for ${{ matrix.dockerfile }}
uses: docker/[email protected]
with:
context: .
push: ${{ contains(github.ref, 'refs/heads/main') || contains(github.ref, 'refs/heads/develop') ||contains(github.head_ref, 'release/') || contains(github.head_ref, 'feature/') || contains(github.head_ref, 'develop') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ matrix.dockerfile }}
- name: Dockle Container Scanner
uses: erzz/dockle-action@v1
continue-on-error: true
if: ${{ contains(github.ref, 'refs/heads/main') || contains(github.head_ref, 'release/') }}
with:
image: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
report-format: sarif
report-name: dockle-report
failure-threshold: fatal
- name: Upload Dockle SARIF Report
uses: github/codeql-action/upload-sarif@v2
continue-on-error: true
if: ${{ contains(github.ref, 'refs/heads/main') || contains(github.head_ref, 'release/') }}
with:
sarif_file: dockle-report.sarif
- name: Trivy Vulnerability Scanner
uses: aquasecurity/trivy-action@master
continue-on-error: true
if: ${{ contains(github.ref, 'refs/heads/main') || contains(github.head_ref, 'release/') }}
with:
image-ref: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy SARIF Report
uses: github/codeql-action/upload-sarif@v2
continue-on-error: true
if: ${{ contains(github.ref, 'refs/heads/main') || contains(github.head_ref, 'release/') }}
with:
sarif_file: 'trivy-results.sarif'
- name: Anchore Container Scan
id: anchore-scan
uses: anchore/[email protected]
continue-on-error: true
if: ${{ contains(github.ref, 'refs/heads/main') || contains(github.head_ref, 'release/') }}
with:
image: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
fail-build: true
severity-cutoff: high
acs-report-enable: true
- name: Upload Anchore Scan SARIF Report
uses: github/codeql-action/upload-sarif@v2
continue-on-error: true
if: ${{ contains(github.ref, 'refs/heads/main') || contains(github.head_ref, 'release/') }}
with:
sarif_file: ${{ steps.anchore-scan.outputs.sarif }}
token: ${{ secrets.GITHUB_TOKEN }}
docs:
runs-on: windows-latest
needs: [build-and-deploy]
env:
SEMVER: ${{ needs.build-and-deploy.outputs.semVer }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v3
with:
dotnet-version: "6.0.x"
- name: Enable NuGet cache
uses: actions/[email protected]
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Setup DocFX
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install docfx
- name: Restore dependencies
run: dotnet restore
working-directory: ./src
- name: Build Solution
run: dotnet build -c ${{ env.BUILD_CONFIG }} --nologo ${{ env.SOLUTION }}
working-directory: ./src
- name: Update docs version
run: |
sed -i -e "s,v0.0.0,v${{ env.SEMVER }},g" ./docs/docfx.json
sed -i -e "s,v0.0.0,v${{ env.SEMVER }},g" ./docs/index.md
- name: Build Docs
working-directory: docs
run: docfx docfx.json
continue-on-error: false
- name: Package docs
run: |
mkdir ~\release
Compress-Archive -Path docs\_site\* -DestinationPath ~\release\mwm-docs-${{ env.SEMVER }}.zip
Get-ChildItem ~\release -Recurse
- name: Upload docs
uses: actions/[email protected]
with:
name: artifacts
path: ~/release
retention-days: 7
release:
if: ${{ contains(github.ref, 'refs/heads/main') || contains(github.ref, 'refs/heads/develop') ||contains(github.head_ref, 'release/') || contains(github.head_ref, 'feature/') || contains(github.head_ref, 'develop') }}
runs-on: ubuntu-latest
needs: [build-and-deploy, docs]
env:
SEMVER: ${{ needs.build-and-deploy.outputs.semVer }}
MAJORMINORPATCH: ${{ needs.build-and-deploy.outputs.majorMinorPatch }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
id: download
- name: List artifacts
run: ls -ldR ${{steps.download.outputs.download-path}}/**/*
- name: Extract owner and repo
uses: jungwinter/split@v2
id: repo
with:
separator: "/"
msg: ${{ github.repository }}
- name: Install GitReleaseManager
uses: gittools/actions/gitreleasemanager/[email protected]
with:
versionSpec: "0.13.x"
- name: Create release with GitReleaseManager
uses: gittools/actions/gitreleasemanager/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ steps.repo.outputs._0 }}
repository: ${{ steps.repo.outputs._1 }}
milestone: ${{ env.MAJORMINORPATCH }}
name: "Release v${{ env.MAJORMINORPATCH }}"
assets: |
artifacts/mwm-docs-${{ env.SEMVER }}.zip
- name: Publish release with GitReleaseManager
uses: gittools/actions/gitreleasemanager/[email protected]
if: ${{ contains(github.ref, 'refs/heads/main') }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ steps.repo.outputs._0 }}
repository: ${{ steps.repo.outputs._1 }}
tagName: ${{ env.MAJORMINORPATCH }}
- name: Close release with GitReleaseManager
uses: gittools/actions/gitreleasemanager/[email protected]
if: ${{ contains(github.ref, 'refs/heads/main') }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ steps.repo.outputs._0 }}
repository: ${{ steps.repo.outputs._1 }}
milestone: ${{ env.MAJORMINORPATCH }}
- name: Unzip docs
if: ${{ contains(github.ref, 'refs/heads/main') }}
run: |
mkdir userguide
unzip artifacts/mwm-docs-${{ env.SEMVER }}.zip -d userguide/
ls -lR userguide/
- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3
if: ${{ contains(github.ref, 'refs/heads/main') }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: userguide/
publish_branch: docs