Skip to content

Comments

Create Docker.yml#338

Merged
Dargon789 merged 1 commit intomainfrom
Dargon789-patch-1
Jan 23, 2026
Merged

Create Docker.yml#338
Dargon789 merged 1 commit intomainfrom
Dargon789-patch-1

Conversation

@Dargon789
Copy link
Owner

@Dargon789 Dargon789 commented Jan 18, 2026

Motivation

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Summary by Sourcery

Build:

  • Introduce a Docker GitHub Actions workflow that logs into Docker Hub, builds images with buildx, tags them based on branch, semver, and SHA, and pushes them on non-PR events while only loading them for pull requests.

Signed-off-by: Dargon789 <[email protected]>
@codesandbox
Copy link

codesandbox bot commented Jan 18, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@gemini-code-assist
Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@snyk-io
Copy link

snyk-io bot commented Jan 18, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 18, 2026

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

Repository owner deleted a comment from vercel bot Jan 18, 2026
Copy link

@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 - I've found 2 issues, and left some high level feedback:

  • The workflow never checks out the repository before building, so docker/build-push-action will build from an empty context; add an actions/checkout step before the build.
  • The Docker login step runs unconditionally and will fail for PRs from forks where REGISTRY_USER/REGISTRY_TOKEN secrets are unavailable; consider skipping login (and any push-related behavior) on pull_request events from forks.
  • In the docker/metadata-action configuration, branch=$repo.default_branch is not a standard expression for this action; replace it with a concrete branch name (e.g., branch=main) or a supported context to ensure edge tags are generated correctly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The workflow never checks out the repository before building, so `docker/build-push-action` will build from an empty context; add an `actions/checkout` step before the build.
- The Docker login step runs unconditionally and will fail for PRs from forks where `REGISTRY_USER`/`REGISTRY_TOKEN` secrets are unavailable; consider skipping login (and any push-related behavior) on `pull_request` events from forks.
- In the `docker/metadata-action` configuration, `branch=$repo.default_branch` is not a standard expression for this action; replace it with a concrete branch name (e.g., `branch=main`) or a supported context to ensure edge tags are generated correctly.

## Individual Comments

### Comment 1
<location> `.github/workflows/Docker.yml:33-34` </location>
<code_context>
+          username: ${{ secrets.REGISTRY_USER }}
+          password: ${{ secrets.REGISTRY_TOKEN }}
+      
+      - name: Setup Docker buildx
+        uses: docker/setup-buildx-action@v3
+
+      # Extract metadata (tags, labels) for Docker
</code_context>

<issue_to_address>
**issue (bug_risk):** The workflow never checks out the repository before building the Docker image

Because there’s no `actions/checkout` step, the repository files are never present on the runner, so `docker/build-push-action`’s default build context will be essentially empty and the Docker build may fail or produce a broken image. Add a checkout step (e.g. `uses: actions/checkout@v4`) before setting up Buildx so the build context includes the repo contents.
</issue_to_address>

### Comment 2
<location> `.github/workflows/Docker.yml:44-45` </location>
<code_context>
+          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+          labels: |
+            org.opencontainers.image.revision=${{ env.SHA }}
+          tags: |
+            type=edge,branch=$repo.default_branch
+            type=semver,pattern=v{{version}}
+            type=sha,prefix=,suffix=,format=short
</code_context>

<issue_to_address>
**issue (bug_risk):** The `type=edge` tag configuration uses an undefined `$repo.default_branch` variable

`docker/metadata-action` does not support `$repo.default_branch` and will treat it as a literal string, so the edge tag won’t work as intended. Use the actual default branch instead (e.g. `type=edge,branch=main`) or one of the action’s supported templates (e.g. `{{branch}}`), aligned with your repo’s true default branch.
</issue_to_address>

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.

@Dargon789 Dargon789 merged commit 2ad832a into main Jan 23, 2026
12 of 16 checks passed
@Dargon789 Dargon789 deleted the Dargon789-patch-1 branch January 23, 2026 01:11
@Dargon789 Dargon789 linked an issue Jan 23, 2026 that may be closed by this pull request
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.

# Sequence diagram for Docker image build and publish workflow

1 participant