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