|
47 | 47 | pull_request: |
48 | 48 | paths: |
49 | 49 | - "Dockerfile" |
| 50 | + - "Dockerfile.push-gateway" |
50 | 51 | - ".dockerignore" |
51 | 52 | - ".github/workflows/docker.yml" |
52 | 53 | - "Cargo.toml" |
@@ -304,3 +305,150 @@ jobs: |
304 | 305 | echo "gh attestation verify oci://${IMAGE_NAME}@${MERGED_DIGEST} --owner block" |
305 | 306 | echo '```' |
306 | 307 | } >> "$GITHUB_STEP_SUMMARY" |
| 308 | +
|
| 309 | + push-gateway-build: |
| 310 | + name: Build public push gateway (${{ matrix.platform }}) |
| 311 | + runs-on: ${{ matrix.runner }} |
| 312 | + timeout-minutes: 60 |
| 313 | + permissions: |
| 314 | + contents: read |
| 315 | + packages: write |
| 316 | + strategy: |
| 317 | + fail-fast: false |
| 318 | + matrix: |
| 319 | + include: |
| 320 | + - platform: linux/amd64 |
| 321 | + runner: ubuntu-24.04 |
| 322 | + arch: amd64 |
| 323 | + - platform: linux/arm64 |
| 324 | + runner: ubuntu-24.04-arm |
| 325 | + arch: arm64 |
| 326 | + steps: |
| 327 | + - name: Checkout |
| 328 | + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 |
| 329 | + with: |
| 330 | + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }} |
| 331 | + persist-credentials: false |
| 332 | + - name: Set up Docker Buildx |
| 333 | + uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 |
| 334 | + with: |
| 335 | + buildkitd-config-inline: | |
| 336 | + [worker.oci] |
| 337 | + max-parallelism = 2 |
| 338 | + - name: Log in to GHCR |
| 339 | + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository |
| 340 | + uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 |
| 341 | + with: |
| 342 | + registry: ghcr.io |
| 343 | + username: ${{ github.repository_owner }} |
| 344 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 345 | + - name: Extract metadata |
| 346 | + id: meta |
| 347 | + uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0 |
| 348 | + with: |
| 349 | + images: ghcr.io/block/buzz-push-gateway |
| 350 | + labels: | |
| 351 | + org.opencontainers.image.title=Buzz Push Gateway |
| 352 | + org.opencontainers.image.description=Capability-gated APNs last hop for Buzz |
| 353 | + org.opencontainers.image.licenses=Apache-2.0 |
| 354 | + - name: Build and push by digest |
| 355 | + id: build |
| 356 | + uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0 |
| 357 | + with: |
| 358 | + context: . |
| 359 | + file: ./Dockerfile.push-gateway |
| 360 | + platforms: ${{ matrix.platform }} |
| 361 | + labels: ${{ steps.meta.outputs.labels }} |
| 362 | + outputs: type=image,name=ghcr.io/block/buzz-push-gateway,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} |
| 363 | + cache-from: type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:${{ matrix.arch }} |
| 364 | + cache-to: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && format('type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:{0},mode=max,compression=zstd', matrix.arch) || '' }} |
| 365 | + - name: Export digest |
| 366 | + if: github.event_name != 'pull_request' |
| 367 | + env: |
| 368 | + DIGEST: ${{ steps.build.outputs.digest }} |
| 369 | + run: mkdir -p /tmp/gateway-digests && touch "/tmp/gateway-digests/${DIGEST#sha256:}" |
| 370 | + - name: Upload digest |
| 371 | + if: github.event_name != 'pull_request' |
| 372 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 373 | + with: |
| 374 | + name: gateway-digests-${{ matrix.arch }} |
| 375 | + path: /tmp/gateway-digests/* |
| 376 | + if-no-files-found: error |
| 377 | + retention-days: 1 |
| 378 | + |
| 379 | + push-gateway-merge: |
| 380 | + name: Publish public push gateway image |
| 381 | + if: github.event_name != 'pull_request' |
| 382 | + runs-on: ubuntu-24.04 |
| 383 | + needs: push-gateway-build |
| 384 | + timeout-minutes: 15 |
| 385 | + permissions: |
| 386 | + contents: read |
| 387 | + packages: write |
| 388 | + id-token: write |
| 389 | + attestations: write |
| 390 | + steps: |
| 391 | + - name: Download per-arch digests |
| 392 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 393 | + with: |
| 394 | + path: /tmp/gateway-digests |
| 395 | + pattern: gateway-digests-* |
| 396 | + merge-multiple: true |
| 397 | + - name: Set up Docker Buildx |
| 398 | + uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 |
| 399 | + - name: Log in to GHCR |
| 400 | + uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 |
| 401 | + with: |
| 402 | + registry: ghcr.io |
| 403 | + username: ${{ github.repository_owner }} |
| 404 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 405 | + - name: Extract metadata |
| 406 | + id: meta |
| 407 | + uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0 |
| 408 | + with: |
| 409 | + images: ghcr.io/block/buzz-push-gateway |
| 410 | + tags: | |
| 411 | + type=ref,event=branch,enable=${{ github.event_name != 'workflow_dispatch' || inputs.version == '' }} |
| 412 | + type=sha,prefix=sha-,format=short,enable=${{ github.event_name != 'workflow_dispatch' || inputs.version == '' }} |
| 413 | + type=semver,pattern={{version}},match=^relay-v(.*)$,value=${{ inputs.version }} |
| 414 | + type=semver,pattern={{major}}.{{minor}},match=^relay-v(.*)$,value=${{ inputs.version }} |
| 415 | + - name: Merge and publish manifest |
| 416 | + id: manifest |
| 417 | + working-directory: /tmp/gateway-digests |
| 418 | + env: |
| 419 | + META_TAGS: ${{ steps.meta.outputs.tags }} |
| 420 | + run: | |
| 421 | + set -euo pipefail |
| 422 | + tags=(); while IFS= read -r tag; do [ -n "$tag" ] && tags+=("-t" "$tag"); done <<< "$META_TAGS" |
| 423 | + digests=(); for digest in *; do digests+=("ghcr.io/block/buzz-push-gateway@sha256:${digest}"); done |
| 424 | + docker buildx imagetools create "${tags[@]}" "${digests[@]}" |
| 425 | + first_tag=$(echo "$META_TAGS" | head -n1) |
| 426 | + digest=$(docker buildx imagetools inspect "$first_tag" --format '{{json .Manifest}}' | jq -r '.digest') |
| 427 | + echo "digest=${digest}" >> "$GITHUB_OUTPUT" |
| 428 | + - name: Attest gateway image provenance |
| 429 | + uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1 |
| 430 | + with: |
| 431 | + subject-name: ghcr.io/block/buzz-push-gateway |
| 432 | + subject-digest: ${{ steps.manifest.outputs.digest }} |
| 433 | + push-to-registry: true |
| 434 | + - name: Gateway publication summary |
| 435 | + env: |
| 436 | + GATEWAY_DIGEST: ${{ steps.manifest.outputs.digest }} |
| 437 | + GATEWAY_TAGS: ${{ steps.meta.outputs.tags }} |
| 438 | + run: | |
| 439 | + set -euo pipefail |
| 440 | + { |
| 441 | + echo "### Published \`ghcr.io/block/buzz-push-gateway\`" |
| 442 | + echo |
| 443 | + printf "**Digest:** \`%s\`\n" "$GATEWAY_DIGEST" |
| 444 | + echo |
| 445 | + echo '**Tags:**' |
| 446 | + echo "\`\`\`" |
| 447 | + printf '%s\n' "$GATEWAY_TAGS" |
| 448 | + echo "\`\`\`" |
| 449 | + echo |
| 450 | + echo 'Verify provenance before deployment:' |
| 451 | + echo "\`\`\`" |
| 452 | + printf 'gh attestation verify oci://ghcr.io/block/buzz-push-gateway@%s --owner block\n' "$GATEWAY_DIGEST" |
| 453 | + echo "\`\`\`" |
| 454 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments