Skip to content

Conversation

@C4illin
Copy link
Owner

@C4illin C4illin commented May 23, 2025

Summary by Sourcery

Enhance the Docker CI workflow to support multi-architecture builds and automated manifest list merging for both GitHub Container Registry and Docker Hub.

New Features:

  • Publish per-platform image digests as artifacts for later use
  • Merge and push multi-architecture manifest lists to GHCR and Docker Hub

Enhancements:

  • Standardize platform identifiers to linux/amd64 and linux/arm64 in the build matrix
  • Introduce a step to normalize platform names into PLATFORM_PAIR for artifact naming
  • Enable OCI annotations, digest outputs, and GitHub Actions cache in the build stage
  • Clean up branch and tag array syntax in the workflow configuration

CI:

  • Add a new "merge" job to download digests, set up buildx, log in to registries, and push manifest lists
  • Use actions/upload-artifact and download-artifact to pass digests between jobs

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 23, 2025

Reviewer's Guide

This PR refactors and extends the Docker publish workflow to support standardized YAML formatting, multi-architecture builds, per-arch digest export/upload, and a new merge job that consolidates image digests into universal manifests for both GHCR and Docker Hub.

Sequence Diagram: Multi-Arch Docker Image Build and Manifest Merge

sequenceDiagram
    title Sequence Diagram: Multi-Arch Docker Image Build and Manifest Merge
    actor User
    participant GA as GitHub Actions
    participant Build_amd64 as "Build Job (linux/amd64)"
    participant Build_arm64 as "Build Job (linux/arm64)"
    participant Artifacts as "GitHub Artifacts"
    participant Merge as "Merge Job"
    participant GHCR
    participant DockerHub

    User->>GA: Event (Push, Tag, Workflow Dispatch)
    GA->>Build_amd64: Start Build (amd64)
    GA->>Build_arm64: Start Build (arm64)

    par
        Build_amd64->>Build_amd64: Checkout, Setup Buildx
        Build_amd64->>GHCR: Login (if not PR)
        Build_amd64->>DockerHub: Login (if not PR)
        Build_amd64->>Build_amd64: Build image (amd64)
        Build_amd64-->>GHCR: Push amd64 image & manifest
        Build_amd64-->>DockerHub: Push amd64 image & manifest
        note right of Build_amd64: Get digest of pushed amd64 manifest
        Build_amd64->>Artifacts: Upload amd64 digest
    and
        Build_arm64->>Build_arm64: Checkout, Setup Buildx
        Build_arm64->>GHCR: Login (if not PR)
        Build_arm64->>DockerHub: Login (if not PR)
        Build_arm64->>Build_arm64: Build image (arm64)
        Build_arm64-->>GHCR: Push arm64 image & manifest
        Build_arm64-->>DockerHub: Push arm64 image & manifest
        note right of Build_arm64: Get digest of pushed arm64 manifest
        Build_arm64->>Artifacts: Upload arm64 digest
    end

    alt If not Pull Request AND Build Jobs Successful
        GA->>Merge: Start Merge Job
        Merge->>Artifacts: Download all digests
        Merge->>GHCR: Login
        Merge->>GHCR: Create & Push Manifest List (using digests)
        Merge->>DockerHub: Login
        Merge->>DockerHub: Create & Push Manifest List (using digests)
        Merge->>Merge: Inspect final images (optional)
    end
Loading

File-Level Changes

Change Details Files
Standardize workflow YAML formatting
  • Quotation style unified for branch and tag lists
  • Removed trailing whitespace
.github/workflows/docker-publish.yml
Expand and normalize multi-arch build matrix
  • Prefixed matrix.platform entries with "linux/"
  • Updated runner include entries to match new platform names
.github/workflows/docker-publish.yml
Introduce platform-specific environment preparation
  • Added "prepare" step to transform matrix.platform into PLATFORM_PAIR
  • Export PLATFORM_PAIR as GitHub Actions environment variable
.github/workflows/docker-publish.yml
Configure Buildx dynamically for target platforms
  • Passed matrix.platform to docker/setup-buildx-action
  • Unified platforms parameter in docker/build-push-action
.github/workflows/docker-publish.yml
Enhance build-and-push action invocation
  • Replaced hardcoded push logic with dynamic push flags
  • Added annotations and outputs for image metadata
.github/workflows/docker-publish.yml
Export and upload per-architecture digests
  • Added steps to export image digest to file
  • Uploaded digest files as artifacts with retention settings
.github/workflows/docker-publish.yml
Add merge job to create and push manifest lists
  • Downloaded per-arch digests from artifacts
  • Extracted metadata and logged into registries
  • Built and pushed manifest lists for GHCR and Docker Hub
  • Inspected final image manifests
.github/workflows/docker-publish.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @C4illin - I've reviewed your changes - here's some feedback:

  • Add an explicit id: to the docker/build-push-action@v6 step so you can reliably reference its digest output in subsequent steps.
  • Remove or re-enable the commented-out push: line under the build step to ensure images get pushed when not in a PR workflow.
  • Update the prepare‐step comment to match the actual environment variable (PLATFORM_PAIR) you’re setting (it currently refers to PLATFORMS_PAIR).
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@M3dvidek
Copy link

Super. Will update when I go home and test calibre

@C4illin C4illin force-pushed the ci-merge-images branch from 041e2e5 to 00f95b6 Compare May 23, 2025 17:10
@C4illin C4illin merged commit b6cdd37 into main May 23, 2025
3 checks passed
@C4illin C4illin deleted the ci-merge-images branch May 23, 2025 17:12
danmestas pushed a commit to danmestas/ConvertX-openAPI that referenced this pull request Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants