|
143 | 143 |
|
144 | 144 | env: |
145 | 145 | BUILDX_VERSION: "v0.30.1" |
146 | | - BUILDKIT_IMAGE: "moby/buildkit:v0.26.2" |
| 146 | + BUILDKIT_IMAGE: "crazymax/buildkit:6397" |
147 | 147 | DOCKER_ACTIONS_TOOLKIT_MODULE: "@docker/actions-toolkit@0.67.0" |
148 | 148 | COSIGN_VERSION: "v3.0.2" |
149 | 149 | LOCAL_EXPORT_DIR: "/tmp/buildx-output" |
@@ -255,14 +255,16 @@ jobs: |
255 | 255 | } else if (platforms.length === 0) { |
256 | 256 | includes.push({ |
257 | 257 | index: 0, |
258 | | - runner: runner === 'auto' ? 'ubuntu-24.04' : runner |
| 258 | + runner: runner === 'auto' ? 'ubuntu-24.04' : runner, |
| 259 | + tlogUpload: !privateRepo |
259 | 260 | }); |
260 | 261 | } else { |
261 | 262 | platforms.forEach((platform, index) => { |
262 | 263 | includes.push({ |
263 | 264 | index: index, |
264 | 265 | platform: platform, |
265 | | - runner: runner === 'auto' ? ((!privateRepo && platform.startsWith('linux/arm')) ? 'ubuntu-24.04-arm' : 'ubuntu-24.04') : runner |
| 266 | + runner: runner === 'auto' ? ((!privateRepo && platform.startsWith('linux/arm')) ? 'ubuntu-24.04-arm' : 'ubuntu-24.04') : runner, |
| 267 | + tlogUpload: !privateRepo |
266 | 268 | }); |
267 | 269 | }); |
268 | 270 | } |
@@ -340,13 +342,118 @@ jobs: |
340 | 342 | if: ${{ inputs.setup-qemu }} |
341 | 343 | with: |
342 | 344 | image: ${{ inputs.qemu-image }} |
| 345 | + - |
| 346 | + name: Expose GitHub Runtime |
| 347 | + uses: crazy-max/ghaction-github-runtime@v3 |
343 | 348 | - |
344 | 349 | name: Set up Docker Buildx |
| 350 | + id: buildx |
345 | 351 | uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
346 | 352 | with: |
347 | 353 | version: ${{ env.BUILDX_VERSION }} |
348 | 354 | buildkitd-flags: --debug |
349 | | - driver-opts: image=${{ env.BUILDKIT_IMAGE }} |
| 355 | + driver-opts: | |
| 356 | + image=${{ env.BUILDKIT_IMAGE }} |
| 357 | + env.ACTIONS_ID_TOKEN_REQUEST_TOKEN=${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN }} |
| 358 | + env.ACTIONS_ID_TOKEN_REQUEST_URL=${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }} |
| 359 | + buildkitd-config-inline: | |
| 360 | + [cache] |
| 361 | + [cache.gha] |
| 362 | + [cache.gha.sign] |
| 363 | + command = ["ghacache-sign-script.sh"] |
| 364 | + [cache.gha.verify] |
| 365 | + required = true |
| 366 | + [cache.gha.verify.policy] |
| 367 | + timestampTreshold = 1 |
| 368 | + tlogThreshold = ${{ matrix.tlogUpload && '1' || '0' }} |
| 369 | + subjectAlternativeName = "https://github.com/docker/github-builder-experimental/.github/workflows/bake.yml*" |
| 370 | + issuer = "https://token.actions.githubusercontent.com" |
| 371 | + runnerEnvironment = "github-hosted" |
| 372 | + - |
| 373 | + name: Install Cosign |
| 374 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 375 | + env: |
| 376 | + INPUT_COSIGN-VERSION: ${{ env.COSIGN_VERSION }} |
| 377 | + INPUT_BUILDER-NAME: ${{ steps.buildx.outputs.name }} |
| 378 | + INPUT_GHA-CACHE-SIGN-SCRIPT: | |
| 379 | + #!/bin/sh |
| 380 | + set -e |
| 381 | +
|
| 382 | + # Create temporary files |
| 383 | + out_file=$(mktemp) |
| 384 | + in_file=$(mktemp) |
| 385 | + trap 'rm -f "$in_file" "$out_file"' EXIT |
| 386 | + cat > "$in_file" |
| 387 | +
|
| 388 | + set -x |
| 389 | +
|
| 390 | + # Sign with cosign |
| 391 | + cosign sign-blob \ |
| 392 | + --yes \ |
| 393 | + --oidc-provider github-actions \ |
| 394 | + --new-bundle-format \ |
| 395 | + --use-signing-config \ |
| 396 | + --bundle "$out_file" \ |
| 397 | + --tlog-upload=${{ matrix.tlogUpload }} \ |
| 398 | + "$in_file" |
| 399 | +
|
| 400 | + # Output bundle to stdout |
| 401 | + cat "$out_file" |
| 402 | + with: |
| 403 | + script: | |
| 404 | + const fs = require('fs'); |
| 405 | + const os = require('os'); |
| 406 | + const path = require('path'); |
| 407 | + |
| 408 | + const { Buildx } = require('@docker/actions-toolkit/lib/buildx/buildx'); |
| 409 | + const { Cosign } = require('@docker/actions-toolkit/lib/cosign/cosign'); |
| 410 | + const { Install } = require('@docker/actions-toolkit/lib/cosign/install'); |
| 411 | + |
| 412 | + const inpCosignVersion = core.getInput('cosign-version'); |
| 413 | + const inpBuilderName = core.getInput('builder-name'); |
| 414 | + const inpGHACacheSignScript = core.getInput('gha-cache-sign-script'); |
| 415 | +
|
| 416 | + const cosignInstall = new Install(); |
| 417 | + const cosignBinPath = await cosignInstall.download(inpCosignVersion, false, true); |
| 418 | + const cosignPath = await cosignInstall.install(cosignBinPath); |
| 419 | +
|
| 420 | + const cosign = new Cosign(); |
| 421 | + await cosign.printVersion(); |
| 422 | + |
| 423 | + const containerName = `${Buildx.containerNamePrefix}${inpBuilderName}0`; |
| 424 | + |
| 425 | + const ghaCacheSignScriptPath = path.join(os.tmpdir(), `ghacache-sign-script.sh`); |
| 426 | + core.info(`Writing GitHub Actions cache sign script to ${ghaCacheSignScriptPath}`); |
| 427 | + await fs.writeFileSync(ghaCacheSignScriptPath, inpGHACacheSignScript); |
| 428 | + |
| 429 | + core.info(`Copying GitHub Actions cache sign script to BuildKit container ${containerName}`); |
| 430 | + await exec.exec('docker', [ |
| 431 | + 'cp', |
| 432 | + ghaCacheSignScriptPath, |
| 433 | + `${containerName}:/usr/bin/ghacache-sign-script.sh` |
| 434 | + ]); |
| 435 | + await exec.exec('docker', [ |
| 436 | + 'exec', |
| 437 | + containerName, |
| 438 | + 'chmod', '+x', '/usr/bin/ghacache-sign-script.sh' |
| 439 | + ]); |
| 440 | + await exec.exec('docker', [ |
| 441 | + 'exec', |
| 442 | + containerName, |
| 443 | + 'cat', '/usr/bin/ghacache-sign-script.sh' |
| 444 | + ]); |
| 445 | + |
| 446 | + core.info(`Copying cosign binary to BuildKit container ${containerName}`); |
| 447 | + await exec.exec('docker', [ |
| 448 | + 'cp', |
| 449 | + cosignPath, |
| 450 | + `${containerName}:/usr/bin/cosign` |
| 451 | + ]); |
| 452 | + await exec.exec('docker', [ |
| 453 | + 'exec', |
| 454 | + containerName, |
| 455 | + 'chmod', '+x', '/usr/bin/cosign' |
| 456 | + ]); |
350 | 457 | - |
351 | 458 | name: Prepare |
352 | 459 | id: prepare |
@@ -526,23 +633,6 @@ jobs: |
526 | 633 | const imageDigest = inpMetadata[inpTarget]['containerimage.digest']; |
527 | 634 | core.info(imageDigest); |
528 | 635 | core.setOutput('digest', imageDigest); |
529 | | - - |
530 | | - name: Install Cosign |
531 | | - if: ${{ inputs.push }} |
532 | | - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
533 | | - env: |
534 | | - INPUT_COSIGN-VERSION: ${{ env.COSIGN_VERSION }} |
535 | | - with: |
536 | | - script: | |
537 | | - const { Cosign } = require('@docker/actions-toolkit/lib/cosign/cosign'); |
538 | | - const { Install } = require('@docker/actions-toolkit/lib/cosign/install'); |
539 | | - |
540 | | - const cosignInstall = new Install(); |
541 | | - const cosignBinPath = await cosignInstall.download(core.getInput('cosign-version'), false, true); |
542 | | - await cosignInstall.install(cosignBinPath); |
543 | | - |
544 | | - const cosign = new Cosign(); |
545 | | - await cosign.printVersion(); |
546 | 636 | - |
547 | 637 | name: Signing attestation manifests |
548 | 638 | id: signing-attestation-manifests |
|
0 commit comments