Skip to content

# Sequence diagram for Docker image build and publish workflow #342

@Dargon789

Description

@Dargon789

Reviewer's Guide

Adds a new GitHub Actions workflow to build, tag, and publish Docker images to Docker Hub on pushes, tags, and PRs, using buildx, metadata-based tagging, and conditional pushing vs. loading for PRs.

Sequence diagram for Docker image build and publish workflow

sequenceDiagram
  actor Dev
  participant GitHub
  participant Workflow_Docker as Workflow_Docker
  participant Docker_Login_Action as Docker_login_action
  participant Buildx_Action as Docker_setup_buildx_action
  participant Metadata_Action as Docker_metadata_action
  participant Build_Push_Action as Docker_build_push_action
  participant Docker_Registry as docker_io

  Dev->>GitHub: push to main or tag / open PR
  GitHub->>Workflow_Docker: trigger Docker workflow

  Workflow_Docker->>Docker_Login_Action: authenticate with REGISTRY_USER and REGISTRY_TOKEN
  Docker_Login_Action-->>Workflow_Docker: login successful

  Workflow_Docker->>Buildx_Action: setup buildx builder
  Buildx_Action-->>Workflow_Docker: buildx ready

  Workflow_Docker->>Metadata_Action: compute tags and labels
  Metadata_Action-->>Workflow_Docker: tags, labels (including SHA revision)

  Workflow_Docker->>Build_Push_Action: build image with tags and labels
  alt event is push or tag
    Build_Push_Action->>Docker_Registry: push image and metadata
    Docker_Registry-->>Build_Push_Action: push complete
  else event is pull_request
    Build_Push_Action-->>Workflow_Docker: load image locally only (no push)
  end

  Workflow_Docker-->>GitHub: job status and logs returned
Loading

File-Level Changes

Change Details Files
Introduce Docker build and publish GitHub Actions workflow triggered on pushes, tags, and pull requests.
  • Configure workflow triggers for pushes to main, any tag, and all pull request branches
  • Define global environment variables for registry hostname, image name, and commit SHA for labeling
  • Add job that logs into Docker registry using repository secrets for credentials
  • Set up Docker Buildx for advanced build and caching capabilities
  • Use docker/metadata-action to generate tags and labels including OCI revision and semver/sha-based tags
  • Configure docker/build-push-action to build the image, use GitHub Actions cache, and conditionally push or load the image depending on event type
.github/workflows/Docker.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

Originally posted by @sourcery-ai[bot] in #338 (comment)

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions