Playwright #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Playwright | |
| on: workflow_dispatch | |
| jobs: | |
| playwright: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| outputs: | |
| digests: ${{ steps.extract-digests.outputs.digests }} | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v5 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract .NET major version | |
| id: extract_version | |
| shell: pwsh | |
| run: | | |
| [xml]$xml = Get-Content 'Directory.Build.props' | |
| $tfm = $xml.Project.PropertyGroup.TargetFramework | |
| $majorVersion = [regex]::Match($tfm, '\d+').Value | |
| Write-Output "major_version=$majorVersion" >> $env:GITHUB_OUTPUT | |
| - name: Build and push Docker image for Playwright | |
| id: docker_build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| provenance: false | |
| platforms: linux/arm64,linux/amd64 | |
| tags: ghcr.io/mu88/screenshotcreator-playwright:latest,ghcr.io/mu88/screenshotcreator-playwright:${{ steps.extract_version.outputs.major_version }}.0.${{ github.run_number }} | |
| file: src/ScreenshotCreator.Api/Dockerfile-Playwright | |
| - name: Extract generated Docker image digests | |
| id: extract-digests | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = "Stop" | |
| $PSNativeCommandUseErrorActionPreference = $true | |
| $digests = @{} | |
| $images = @( | |
| "ghcr.io/mu88/screenshotcreator-playwright:latest", | |
| "ghcr.io/mu88/screenshotcreator-playwright:${{ steps.extract_version.outputs.major_version }}.0.${{ github.run_number }}" | |
| ) | |
| foreach ($image in $images) { | |
| $manifestOutput = docker manifest inspect $image | |
| $manifest = $manifestOutput | ConvertFrom-Json | |
| # Collect digests from all manifests (for multi-arch images) | |
| foreach ($item in $manifest.manifests) { | |
| $digest = $item.digest | |
| if ($digest -notin $digests) { | |
| $digests += $digest | |
| } | |
| } | |
| # Add the digest for the image itself | |
| $imageDigest = docker inspect --format='{{index .Descriptor.digest}}' $image | |
| if ($imageDigest -notin $digests) { | |
| $digests += $imageDigest | |
| } | |
| } | |
| $json = $digests | ConvertTo-Json -Depth 10 | |
| Write-Output "digests=$json" >> $env:GITHUB_OUTPUT | |
| attest_provenance_sbom: | |
| name: 'Attest Docker image build provenance and SBOM' | |
| runs-on: ubuntu-latest | |
| needs: playwright | |
| strategy: | |
| matrix: | |
| digest: ${{ fromJson(needs.playwright.outputs.digests) }} | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v5 | |
| - name: Login to Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Attest build provenance | |
| uses: actions/attest-build-provenance@v3 | |
| with: | |
| push-to-registry: true | |
| subject-name: ghcr.io/mu88/screenshotcreator-playwright | |
| subject-digest: ${{ matrix.digest }} | |
| - name: Generate SBOM | |
| uses: anchore/sbom-action@v0 | |
| with: | |
| image: ghcr.io/mu88/screenshotcreator-playwright@${{ matrix.digest }} | |
| output-file: sbom.json | |
| - name: Attest SBOM | |
| uses: actions/attest-sbom@v2 | |
| with: | |
| push-to-registry: true | |
| sbom-path: sbom.json | |
| subject-name: ghcr.io/mu88/screenshotcreator-playwright | |
| subject-digest: ${{ matrix.digest }} |