5
5
pull_request :
6
6
workflow_dispatch :
7
7
8
+ permissions :
9
+ contents : read
10
+
8
11
concurrency :
9
12
group : push-lock-${{ github.ref }}
10
13
cancel-in-progress : true
@@ -54,10 +57,11 @@ jobs:
54
57
shell : pwsh
55
58
run : |
56
59
$prefix = "run-windows-${{ matrix.tag }}-${{ matrix.vendor }}-${{ matrix.config }}"
57
- $repo = $env:GITHUB_REPOSITORY
58
- $tag = "nsc-godbolt-build-${{ matrix.vendor }}-${{ matrix.config }}-${{ matrix.tag }}"
59
- $nscTargetTaggedImage = "ghcr.io/${repo}:${tag}".ToLower()
60
- $nscTargetTaggedImageLatest = "ghcr.io/${repo}:nsc-godbolt-latest".ToLower()
60
+ $owner = "${{ github.repository_owner }}"
61
+ $package = "nabla-shader-compiler-godbolt"
62
+ $tag = "build-${{ matrix.vendor }}-${{ matrix.config }}-${{ matrix.tag }}"
63
+ $nscTargetTaggedImage = "ghcr.io/${owner}/${package}:${tag}".ToLower()
64
+ $nscTargetTaggedImageLatest = "ghcr.io/${owner}/${package}:latest".ToLower()
61
65
62
66
$shouldPushImage = (
63
67
"${{ github.ref }}" -eq "refs/heads/master" -and
@@ -178,4 +182,72 @@ jobs:
178
182
- name : Push images to GHCR
179
183
if : steps.set-prefix.outputs.shouldPushImage == 'True'
180
184
run : |
181
- docker push ${{ steps.set-prefix.outputs.nscTargetTaggedImageLatest }}
185
+ docker push ${{ steps.set-prefix.outputs.nscTargetTaggedImageLatest }}
186
+
187
+ update-badges :
188
+ name : Update Build & Image Badges
189
+ if : ${{ always() && github.ref == 'refs/heads/master' }}
190
+ needs : build-windows
191
+ runs-on : windows-2022
192
+ permissions :
193
+ contents : write
194
+
195
+ steps :
196
+ - name : Checkout
197
+ uses : actions/checkout@v4
198
+
199
+ - name : Create Build Badge
200
+ run : |
201
+ $jobStatus = "${{ needs.build-windows.result }}"
202
+ $buildMsg = if ($jobStatus -eq "success") { "passing" } else { "failing" }
203
+ $buildColor = if ($jobStatus -eq "success") { "brightgreen" } else { "red" }
204
+
205
+ $buildBadge = @{
206
+ schemaVersion = 1
207
+ label = "build"
208
+ message = $buildMsg
209
+ color = $buildColor
210
+ } | ConvertTo-Json -Depth 2
211
+
212
+ $buildPath = ".badge-public/nabla"
213
+ New-Item -ItemType Directory -Path $buildPath -Force | Out-Null
214
+ $buildBadge | Set-Content -Path "$buildPath/build.json" -Encoding utf8
215
+
216
+ - name : Create Image Size Badge
217
+ run : |
218
+ $owner = "${{ github.repository_owner }}"
219
+ $package = "nabla-shader-compiler-godbolt"
220
+ $image = "ghcr.io/${owner}/${package}:latest".ToLower()
221
+ $manifest = docker manifest inspect $image | ConvertFrom-Json
222
+
223
+ if ($manifest.manifests) {
224
+ $totalSize = ($manifest.manifests | Measure-Object -Property size -Sum).Sum
225
+ } elseif ($manifest.layers) {
226
+ $totalSize = ($manifest.layers | Measure-Object -Property size -Sum).Sum
227
+ } else {
228
+ Write-Error "No valid size information found in manifest."
229
+ exit 1
230
+ }
231
+
232
+ $sizeMB = [Math]::Round($totalSize / 1MB, 2)
233
+ $size = "$sizeMB MB"
234
+
235
+ $imageBadge = @{
236
+ schemaVersion = 1
237
+ label = $image
238
+ message = $size
239
+ color = "blue"
240
+ } | ConvertTo-Json -Depth 2
241
+
242
+ $imagePath = ".badge-public/packages/nabla-shader-compiler-nsc"
243
+ New-Item -ItemType Directory -Path $imagePath -Force | Out-Null
244
+ $imageBadge | Set-Content -Path "$imagePath/image-badge.json" -Encoding utf8
245
+
246
+ - name : Deploy Badges
247
+ uses : peaceiris/actions-gh-pages@v3
248
+ with :
249
+ github_token : ${{ secrets.GITHUB_TOKEN }}
250
+ publish_branch : badges
251
+ publish_dir : .badge-public
252
+ keep_files : true
253
+ commit_message : " [CI] badges update"
0 commit comments